feat: add optional device parameter to Recorder

This commit is contained in:
2026-04-10 21:03:57 +02:00
parent 484df3b9fd
commit 1d19a197c7
2 changed files with 22 additions and 1 deletions
+9 -1
View File
@@ -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")