|
|
@ -1,5 +1,4 @@ |
|
|
|
#!/usr/bin/env python3 |
|
|
|
#!/usr/bin/env python3 |
|
|
|
import sounddevice as sd |
|
|
|
|
|
|
|
import numpy as np |
|
|
|
import numpy as np |
|
|
|
|
|
|
|
|
|
|
|
from cereal import messaging |
|
|
|
from cereal import messaging |
|
|
@ -84,11 +83,11 @@ class Mic: |
|
|
|
|
|
|
|
|
|
|
|
self.measurements = self.measurements[FFT_SAMPLES:] |
|
|
|
self.measurements = self.measurements[FFT_SAMPLES:] |
|
|
|
|
|
|
|
|
|
|
|
def micd_thread(self, device=None): |
|
|
|
def micd_thread(self): |
|
|
|
if device is None: |
|
|
|
# sounddevice must be imported after forking processes |
|
|
|
device = "sysdefault" |
|
|
|
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=}") |
|
|
|
cloudlog.info(f"micd stream started: {stream.samplerate=} {stream.channels=} {stream.dtype=} {stream.device=}") |
|
|
|
while True: |
|
|
|
while True: |
|
|
|
self.update() |
|
|
|
self.update() |
|
|
|