From feba2f3fe566114325f8c9119540fb19cf401a4a Mon Sep 17 00:00:00 2001 From: Cameron Clough Date: Mon, 30 Jan 2023 17:41:42 -0800 Subject: [PATCH] fix micd input device (#27160) * try no device * unused * move sounddevice import --- system/micd.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/system/micd.py b/system/micd.py index a56140e3b..97ba0c262 100755 --- a/system/micd.py +++ b/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()