fix micd input device (#27160)

* try no device

* unused

* move sounddevice import
pull/27161/head
Cameron Clough 2 years ago committed by GitHub
parent 549e4d9636
commit feba2f3fe5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      system/micd.py

@ -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()

Loading…
Cancel
Save