Open Terminazor opened 2 years ago
is it somehow possible to use .read() AND occassionally .rec() with the same input device/microphone?
Yes, but depending on the host API, the two streams might not be able to exist at the same time.
BTW, using a stream in a threading.Thread
is not easy to get right, you can search the issues here for "threading" to see some potential problems.
I normally find it easier to use the "callback" mode. This way, a separate thread it automatically created by the PortAudio library, and in many cases it is not necessary to explicitly create a threading.Thread
with Python.
I would try to create a single callback function that takes care of both the analyzing and the on-demand recording.
You can find an example for this in examples/rec_gui.py, where a meter is continuously showing the sound level, but the signal is recorded only on demand.
Hi,
i have a program with two containers/two python scripts for an AI application. One is using sd.InputStream and the .read() function to continuously read chunks out of the audiostream and analyse it. And the other container is using the sd.rec() function to record/save new training samples, but only when the user gives a signal (aka send a mqtt message). My question is, is it somehow possible to use .read() AND occassionally .rec() with the same input device/microphone?
Relevant part of the analyze.py file:
Relevant part of recording.py: