diff --git a/platypush/plugins/sound.py b/platypush/plugins/sound.py index c16100ed2b..928d8f5011 100644 --- a/platypush/plugins/sound.py +++ b/platypush/plugins/sound.py @@ -10,8 +10,6 @@ import time from enum import Enum from threading import Thread, Event, RLock -import sounddevice as sd - from platypush.plugins import Plugin, action @@ -114,6 +112,8 @@ class SoundPlugin(Plugin): """ + import sounddevice as sd + devs = sd.query_devices() if category == 'input': devs = [d for d in devs if d.get('max_input_channels') > 0] @@ -141,6 +141,8 @@ class SoundPlugin(Plugin): :type bufsize: int """ + import sounddevice as sd + if self._get_playback_state() != PlaybackState.STOPPED: self.stop_playback() time.sleep(2) @@ -267,6 +269,8 @@ class SoundPlugin(Plugin): :type subtype: str """ + import sounddevice as sd + if self._get_recording_state() != RecordingState.STOPPED: self.stop_recording() time.sleep(2) @@ -375,6 +379,8 @@ class SoundPlugin(Plugin): :type dtype: str """ + import sounddevice as sd + if self._get_playback_state() != PlaybackState.STOPPED: self.stop_playback() time.sleep(2)