examples.mic_live¶
Live Speech Transcription - Real-time with Voice Activity Detection Transcribes speech as you talk, detecting when you pause to process audio.
View the complete module source at #L1-L245.
API details¶
Each callable below includes its exact signature, type annotations, inputs, defaults, return contract, documented exceptions, implementation source, and parsed docstring sections when the source provides them.
examples.mic_live
¶
Live Speech Transcription - Real-time with Voice Activity Detection
Transcribes speech as you talk, detecting when you pause to process audio. Much more natural than fixed-chunk transcription.
Usage
python examples/mic_live.py python examples/mic_live.py --model parakeet # Faster for English
Requirements
pip install sounddevice soundfile numpy
examples.mic_live.MODEL_ALIASES
module-attribute
¶
MODEL_ALIASES = {'whisper-small': 'mlx-community/whisper-small-mlx', 'whisper-medium': 'mlx-community/whisper-medium-mlx', 'whisper-large-v3': 'mlx-community/whisper-large-v3-mlx', 'whisper-turbo': 'mlx-community/whisper-large-v3-turbo', 'parakeet': 'mlx-community/parakeet-tdt-0.6b-v2'}
examples.mic_live.LiveTranscriber
¶
Live transcription with voice activity detection.
Source code in examples/mic_live.py
examples.mic_live.LiveTranscriber.silence_duration_ms
instance-attribute
¶
examples.mic_live.LiveTranscriber.audio_buffer
instance-attribute
¶
audio_buffer = deque(maxlen=SAMPLE_RATE * 30)
examples.mic_live.LiveTranscriber.load_model
¶
examples.mic_live.LiveTranscriber.get_audio_level
¶
examples.mic_live.LiveTranscriber.audio_callback
¶
examples.mic_live.LiveTranscriber.transcribe_audio
¶
Transcribe audio array.
Source code in examples/mic_live.py
examples.mic_live.LiveTranscriber.process_audio_stream
¶
Process audio with VAD.
Source code in examples/mic_live.py
examples.mic_live.LiveTranscriber.run
¶
Start live transcription.
Source code in examples/mic_live.py
examples.mic_live.main
¶
Source code in examples/mic_live.py
Complete contract reference¶
Expand any definition for its exact inputs, annotations, defaults, return contract, directly raised exceptions, source-grounded behavior, and immutable line link. This section includes private and nested definitions that ordinary API generators omit.
examples.mic_live.LiveTranscriber Β· class
Live transcription with voice activity detection.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
model_name |
str |
yes |
none |
Required positional or keyword input. |
language |
str |
no |
None |
Optional positional or keyword input; defaults to None. |
Returns
- Constructs:
examples.mic_live.LiveTranscriber
Exceptions and behavior
Class LiveTranscriber declares 7 direct member(s).
No direct raise statement appears in this definition.
examples.mic_live.LiveTranscriber.__init__ Β· method
Method LiveTranscriber.__init__ updates self.model_name, self.language, self.silence_threshold, self.speech_pad_ms; calls deque, queue.Queue.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
model_name |
str |
yes |
none |
Required positional or keyword input. |
language |
str |
no |
None |
Optional positional or keyword input; defaults to None. |
Returns
- Type:
not annotated
Exceptions and behavior
Method LiveTranscriber.__init__ updates self.model_name, self.language, self.silence_threshold, self.speech_pad_ms; calls deque, queue.Queue.
No direct raise statement appears in this definition.
examples.mic_live.LiveTranscriber.load_model Β· method
Load STT model.
Parameters
This callable has no explicit inputs.
Returns
- Type:
not annotated
Exceptions and behavior
Method LiveTranscriber.load_model updates self.engine; calls print, STTEngine, self.engine.load.
No direct raise statement appears in this definition.
examples.mic_live.LiveTranscriber.get_audio_level Β· method
Get RMS audio level.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
audio |
not annotated |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
not annotated - Direct return expressions:
np.sqrt(np.mean(audio ** 2))
Exceptions and behavior
Method LiveTranscriber.get_audio_level calls np.sqrt, np.mean; returns np.sqrt(np.mean(audio ** 2)).
No direct raise statement appears in this definition.
examples.mic_live.LiveTranscriber.audio_callback Β· method
examples.mic_live.LiveTranscriber.audio_callback(indata, frames, time_info, status) -> not annotated
Audio input callback.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
indata |
not annotated |
yes |
none |
Required positional or keyword input. |
frames |
not annotated |
yes |
none |
Required positional or keyword input. |
time_info |
not annotated |
yes |
none |
Required positional or keyword input. |
status |
not annotated |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
not annotated
Exceptions and behavior
Method LiveTranscriber.audio_callback calls self.audio_queue.put, time.time, indata.copy().flatten, indata.copy.
No direct raise statement appears in this definition.
examples.mic_live.LiveTranscriber.transcribe_audio Β· method
Transcribe audio array.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
audio |
not annotated |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
not annotated - Direct return expressions:
result.text.strip()
Exceptions and behavior
Method LiveTranscriber.transcribe_audio calls tempfile.NamedTemporaryFile, sf.write, self.engine.transcribe, result.text.strip; returns result.text.strip().
No direct raise statement appears in this definition.
examples.mic_live.LiveTranscriber.process_audio_stream Β· method
Process audio with VAD.
Parameters
This callable has no explicit inputs.
Returns
- Type:
not annotated
Exceptions and behavior
Method LiveTranscriber.process_audio_stream updates self.is_speaking, self.speech_start, self.last_speech_time; calls self.audio_queue.get, self.get_audio_level, print, speech_buffer.extend.
No direct raise statement appears in this definition.
examples.mic_live.LiveTranscriber.run Β· method
Start live transcription.
Parameters
This callable has no explicit inputs.
Returns
- Type:
not annotated - Direct return expressions:
self.full_transcript
Exceptions and behavior
Method LiveTranscriber.run updates self.running; calls print, threading.Thread, process_thread.start, sd.InputStream; returns self.full_transcript.
No direct raise statement appears in this definition.
examples.mic_live.main Β· function
Function main calls argparse.ArgumentParser, parser.add_argument, parser.parse_args, print.
Parameters
This callable has no explicit inputs.
Returns
- Type:
not annotated
Exceptions and behavior
Function main calls argparse.ArgumentParser, parser.add_argument, parser.parse_args, print.
No direct raise statement appears in this definition.
Complete symbol map¶
This map also includes private definitions and nested helpers. The signature column exposes every explicit input even when an internal helper has no dedicated parameter prose.
| Symbol | Kind | Signature and inputs | What it does | Source |
|---|---|---|---|---|
LiveTranscriber |
class | LiveTranscriber(model_name: str, language: str = None) |
Live transcription with voice activity detection. | #L42-L201 |
LiveTranscriber.__init__ |
method | LiveTranscriber.__init__(model_name: str, language: str = None) -> not annotated |
Method LiveTranscriber.__init__ updates self.model_name, self.language, self.silence_threshold, self.speech_pad_ms; calls deque, queue.Queue. |
#L45-L68 |
LiveTranscriber.load_model |
method | LiveTranscriber.load_model() -> not annotated |
Load STT model. | #L70-L76 |
LiveTranscriber.get_audio_level |
method | LiveTranscriber.get_audio_level(audio) -> not annotated |
Get RMS audio level. | #L78-L80 |
LiveTranscriber.audio_callback |
method | LiveTranscriber.audio_callback(indata, frames, time_info, status) -> not annotated |
Audio input callback. | #L82-L85 |
LiveTranscriber.transcribe_audio |
method | LiveTranscriber.transcribe_audio(audio) -> not annotated |
Transcribe audio array. | #L87-L99 |
LiveTranscriber.process_audio_stream |
method | LiveTranscriber.process_audio_stream() -> not annotated |
Process audio with VAD. | #L101-L160 |
LiveTranscriber.run |
method | LiveTranscriber.run() -> not annotated |
Start live transcription. | #L162-L201 |
main |
function | main() -> not annotated |
Function main calls argparse.ArgumentParser, parser.add_argument, parser.parse_args, print. |
#L204-L241 |