Path: blob/master/examples/pyaudio-streaming/pyaudio-streaming-examples.ipynb
1150 views
Pyaudio Microphone Streaming Examples
A simple notebook that uses pyaudio to get the microphone audio and feeds this audio then to Silero VAD.
I created it as an example on how binary data from a stream could be feed into Silero VAD.
Has been tested on Ubuntu 21.04 (x86). After you installed the dependencies below, no additional setup is required.
This notebook does not work in google colab! For local usage only.
Dependencies
The cell below lists all used dependencies and the used versions. Uncomment to install them from within the notebook.
Imports
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Cell In[2], line 8
6 import matplotlib
7 import matplotlib.pylab as plt
----> 8 import pyaudio
ModuleNotFoundError: No module named 'pyaudio'
Helper Methods
Pyaudio Set-up
Simple Example
The following example reads the audio as 250ms chunks from the microphone, converts them to a Pytorch Tensor, and gets the probabilities/confidences if the model thinks the frame is voiced.
Real Time Visualization
As an enhancement to plot the speech probabilities in real time I added the implementation below. In contrast to the simeple one, it records the audio until to stop the recording by pressing enter. While looking into good ways to update matplotlib plots in real-time, I found a simple libarary that does the job. https://github.com/lvwerra/jupyterplot It has some limitations, but works for this use case really well.