Learn how to transcribe streaming audio in Python.
extras
enable additional features, such as streaming audio from a microphone.YOUR_API_KEY
with your copied API key.RealtimeTranscriber
using the function you created.sample_rate
is the number of audio samples per second, measured in hertz (Hz). Higher sample rates result in higher quality audio, which may lead to better transcripts, but also more data being sent over the network.We recommend the following sample rates:8_000
(8 kHz)16_000
(16 kHz)48_000
(48 kHz)on_open
function you created earlier will be called when the connection has been established.
sample_rate
needs to be the same value as the one you passed to RealtimeTranscriber
.MicrophoneStream
formats the audio data for you. If you want to stream data from elsewhere, make sure that your audio data is in the following format:on_data
function you created earlier will be called when the transcript is sent back.Press Ctrl+C
to stop recording.on_close
function you created earlier will be called when the connection has been closed.