feat: add optional device parameter to Recorder
This commit is contained in:
@@ -9,10 +9,17 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Recorder:
|
||||
def __init__(self, sample_rate: int = 16000, channels: int = 1, min_duration: float = 0.5):
|
||||
def __init__(
|
||||
self,
|
||||
sample_rate: int = 16000,
|
||||
channels: int = 1,
|
||||
min_duration: float = 0.5,
|
||||
device: str | None = None,
|
||||
):
|
||||
self.sample_rate = sample_rate
|
||||
self.channels = channels
|
||||
self.min_duration = min_duration
|
||||
self.device = device
|
||||
self.is_recording = False
|
||||
self._chunks: list[np.ndarray] = []
|
||||
self._stream: sd.InputStream | None = None
|
||||
@@ -31,6 +38,7 @@ class Recorder:
|
||||
channels=self.channels,
|
||||
dtype=np.float32,
|
||||
callback=self._audio_callback,
|
||||
device=self.device,
|
||||
)
|
||||
self._stream.start()
|
||||
logger.info("Aufnahme gestartet")
|
||||
|
||||
Reference in New Issue
Block a user