Overview
Requirements
torch, numpygit+https://github.com/Aratako/MioCodec.git (or miocodec package if available)websockets (streaming)soundfile (offline WAV write) or sounddevice (optional playback)Repository contents (what to push to HF)
weights/ — your lora_windowed checkpoint files (use Git LFS).streaming_istft_head.py — streaming-capable ISTFT head (small helper).windowed_streamer.py — windowed streamer implementation.mio_codec_wrapper.py — wrapper script for streaming and offline decode. See mio_codec_wrapper.py.requirements.txt — environment dependencies. See MioCodec-stream/requirements.txt.Install (inference host)
python3 -m venv ~/mio_env
source ~/mio_env/bin/activate
pip install -r MioCodec-stream/requirements.txt
If you prefer to install MioCodec from the GitHub repo directly:
pip install git+https://github.com/Aratako/MioCodec.git
Usage — Streaming (LLM websocket → audio)
{"embedding": [0.12, 0.34, ...]}
Send a final message { "finished": true } when the utterance completes.
Run the wrapper in streaming mode (plays audio locally if --play):
python mydrive2/Indic-Mio/MioCodec/mio_codec_wrapper.py --mode stream \
--uri ws://localhost:8000/stream --device cpu --play
Notes:
windowed_streamer.py, streaming_istft_head.py) when present; otherwise it will attempt to use the installed miocodec package and swap in the streaming head if available.--chunk-size, --left, --right options to tune streaming latency/quality.Usage — Offline (JSONL tokens → WAV)
embedding array, e.g.:{"embedding": [ ... ]}
{"embedding": [ ... ]}
Run offline decode:
python MioCodec-stream/mio_codec_wrapper.py --mode offline --input tokens.jsonl --out out.wav --device cpu
The wrapper will prefer the windowed_streamer workflow (exact frame accounting). If the streamer is not available it falls back to a best-effort one-shot decode (less exact).
Pushing weights to Hugging Face
weights/ folder to your HF repo. Use Git LFS for large checkpoint files:git lfs install
git lfs track "weights/*"
git add .gitattributes weights/ streaming_istft_head.py windowed_streamer.py mio_codec_wrapper.py requirements.txt
git commit -m "Add weights + streaming helpers"
git push
When calling MioCodecModel.from_pretrained() in the wrapper, you can pass the HF repo id (for example PRIYANSHUDHAKED/Mio-Codec-Stream) so the model code downloads the weights from the hub automatically.
Troubleshooting
BloomPreTrainedModel) usually come from incompatible transformers versions — use the version recommended by the model package or install inside a fresh venv.--right lookahead or ensure windowed_streamer.py is present so exact frame trimming is used.out.wav in a player; the wrapper may write raw float32 if soundfile is unavailable.Next steps / options
README section that shows how to configure a vLLM or other LLM server to emit the expected websocket JSON format. Want that added?lora_windowed/prenet_final/adapter_model.safetensors 2 MiBlora_windowed/prenet_step1000/adapter_model.safetensors 2 MiBlora_windowed/prenet_step1500/adapter_model.safetensors 2 MiBlora_windowed/prenet_step2000/adapter_model.safetensors 2 MiBlora_windowed/prenet_step2500/adapter_model.safetensors 2 MiBlora_windowed/prenet_step500/adapter_model.safetensors 2 MiBlora_windowed/decoder_final/adapter_model.safetensors 2 MiBlora_windowed/decoder_step1000/adapter_model.safetensors 2 MiBlora_windowed/decoder_step1500/adapter_model.safetensors 2 MiBlora_windowed/decoder_step2000/adapter_model.safetensors 2 MiBlora_windowed/decoder_step2500/adapter_model.safetensors 2 MiBlora_windowed/decoder_step500/adapter_model.safetensors 2 MiBlora_windowed/post_final/adapter_model.safetensors 512.9 KiBlora_windowed/post_step1000/adapter_model.safetensors 512.9 KiBlora_windowed/post_step1500/adapter_model.safetensors 512.9 KiBlora_windowed/post_step2000/adapter_model.safetensors 512.9 KiBlora_windowed/post_step2500/adapter_model.safetensors 512.9 KiBlora_windowed/post_step500/adapter_model.safetensors 512.9 KiBlora_windowed/prior_final/adapter_model.safetensors 512.9 KiBlora_windowed/prior_step1000/adapter_model.safetensors 512.9 KiBlora_windowed/prior_step1500/adapter_model.safetensors 512.9 KiBlora_windowed/prior_step2000/adapter_model.safetensors 512.9 KiBlora_windowed/prior_step2500/adapter_model.safetensors 512.9 KiBlora_windowed/prior_step500/adapter_model.safetensors 512.9 KiB