MicTranscriber class extends Transcriber with automatic microphone audio capture, making it easy to transcribe live speech from the system’s default microphone.
Class Definition
Constructor Parameters
Inherits allTranscriber parameters plus:
Audio input device index.
None uses the system default microphone.Use sounddevice.query_devices() to list available devices.Microphone sample rate in Hz. 16000 is optimal for Moonshine models.
Number of audio channels. Must be 1 (mono) for Moonshine.
Audio buffer size in samples. Smaller values reduce latency but may cause audio dropouts.
Methods
Inherits allTranscriber methods. The start() and stop() methods automatically handle microphone capture:
start
Begin microphone capture and transcription.stop() is called.
stop
Stop microphone capture and end the session.Example: Basic Microphone Transcription
Example: Selecting Audio Device
Command-Line Usage
You can run the MicTranscriber directly from the command line:Command-line options
Command-line options
--language- Language code (en, es, ar, ja, ko, zh, uk, vi)--model-arch- Model architecture (0-5)--model-path- Path to model files--device- Audio device index--sample-rate- Sample rate (default: 16000)--update-interval- Update interval in seconds--options- JSON string of advanced options
Audio Processing Pipeline
TheMicTranscriber handles the complete audio pipeline:
- Capture - sounddevice captures audio from microphone
- Buffer - Audio chunks are buffered
- Feed - Chunks are fed to the transcriber via
add_audio() - Process - VAD, segmentation, and transcription happen automatically
- Events - Listeners receive updates as speech is recognized
Configuration Tips
If you experience audio dropouts, increase
blocksize to 2048 or 4096.Permissions
Microphone access requires user permission on most platforms:
- macOS: Add microphone usage description to Info.plist
- Windows: Ensure microphone privacy settings allow access
- Linux: User must be in
audiogroup
Troubleshooting
No audio detected
No audio detected
- Check microphone is working with other apps
- Verify correct device index with
sounddevice.query_devices() - Check VAD threshold - try lowering it:
- Enable debug logging:
Audio dropouts / glitches
Audio dropouts / glitches
- Increase blocksize:
blocksize=2048 - Close other audio applications
- Check system CPU usage
- Try a lower sample rate:
sample_rate=8000
See Also
- Transcriber - Base transcriber class
- Events - Event listener interface
- Microphone Transcription Guide - Complete guide