Download stream_audio.py from mistral-experimental/Voxtral-Mini-4B-Realtime-2602-ExecuTorch: direct link, hf CLI and curl.
- Browser
- Download file 497 Bytes
-
https://huggingface.co/mistral-experimental/Voxtral-Mini-4B-Realtime-2602-ExecuTorch/resolve/main/stream_audio.py
- Command line
-
hf download hf://mistral-experimental/Voxtral-Mini-4B-Realtime-2602-ExecuTorch/stream_audio.py
-
curl -L -o stream_audio.py https://huggingface.co/mistral-experimental/Voxtral-Mini-4B-Realtime-2602-ExecuTorch/resolve/main/stream_audio.py
497 Bytes
| #!/usr/bin/env python3 | |
| """Stream microphone audio to stdout as raw float32 PCM at 16kHz mono.""" | |
| import sys | |
| import sounddevice as sd | |
| SAMPLE_RATE = 16000 | |
| CHANNELS = 1 | |
| DTYPE = "float32" | |
| BLOCK_SIZE = 1024 | |
| stream = sd.RawInputStream(samplerate=SAMPLE_RATE, channels=CHANNELS, dtype=DTYPE, blocksize=BLOCK_SIZE) | |
| stream.start() | |
| try: | |
| while True: | |
| data, _ = stream.read(BLOCK_SIZE) | |
| sys.stdout.buffer.write(bytes(data)) | |
| except KeyboardInterrupt: | |
| stream.stop() | |
| stream.close() | |