liveBook · Manning

Sounddevice

As explained in Data Analysis with LLMs

sounddevice is a Python library for recording and playing audio through sound cards and other audio devices.

sounddevice provides Python functions for recording microphone input. A recording call sets the number of frames, sample rate, and channels; sounddevice.wait() lets capture finish. SciPy can save the result as a WAV file. section 7.3.3

recording = sounddevice.rec(                   #1
    nr_frames, samplerate=sample_rate, channels=1)
sounddevice.wait()                             #2

See the recording call and wait step for a fixed-duration capture. section 7.3.3

A five-second voice query

At 44,100 samples per second, a five-second recording uses 220,500 frames. Saving the audio file can help diagnose silence or background noise. section 7.3.3 section 7.3.4

How Data Analysis with LLMs covers it

How deep it goes
Implements fixed-duration capture and WAV saving, while deferring continuous recording and pause detection.
Examples
Records five-second voice queries at 44,100 Hz and saves them as WAV files for quality checks.
What it assumes
Assumes access to a computer microphone and shows installation of sounddevice and SciPy.
What you can do after
Apply sounddevice.rec and sounddevice.wait to capture fixed-duration microphone input.
How it connects
Connects microphone recording with SciPy WAV writing, audio transcription, voice queries, and speech translation.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data Analysis with LLMs. The section links point to the parts of the book it draws on.