fix micd input device (#27160)

* try no device

* unused

* move sounddevice import
old-commit-hash: feba2f3fe566114325f8c9119540fb19cf401a4a
This commit is contained in:
Cameron Clough
2023-01-30 17:41:42 -08:00
committed by GitHub
parent 2e62b4f08c
commit cc0090c8d2
+4 -5
View File
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
import sounddevice as sd
import numpy as np
from cereal import messaging
@@ -84,11 +83,11 @@ class Mic:
self.measurements = self.measurements[FFT_SAMPLES:]
def micd_thread(self, device=None):
if device is None:
device = "sysdefault"
def micd_thread(self):
# sounddevice must be imported after forking processes
import sounddevice as sd # pylint: disable=import-outside-toplevel
with sd.InputStream(device=device, channels=1, samplerate=SAMPLE_RATE, callback=self.callback) as stream:
with sd.InputStream(channels=1, samplerate=SAMPLE_RATE, callback=self.callback) as stream:
cloudlog.info(f"micd stream started: {stream.samplerate=} {stream.channels=} {stream.dtype=} {stream.device=}")
while True:
self.update()