Skip to content

Fact · Speech recognition

The python-sounddevice package records audio from the sound device into a NumPy array with its rec() function.

Checked against its source on October 17, 2026

In the source's own words

“To record audio data from your sound device into a NumPy array, you can use rec()”

Play and Record Sound with Python: Usage (python-sounddevice), Matthias Geier, python-sounddevice documentation, n.d., Recording.

Open the original
What it measures
The usage page gives rec() a duration and a samplerate, and you pass the sampling rate yourself. The package sits on the PortAudio library.
What it does not show
Recording needs the sample rate your model expects. Set the samplerate argument explicitly rather than relying on the device default.

Source

sounddevice records into a NumPy array with rec() | Yap