Only import sounddevice when needed
This commit is contained in:
parent
abd88d0a71
commit
28223cab30
1 changed files with 8 additions and 2 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue