59 lines
2.2 KiB
Markdown
59 lines
2.2 KiB
Markdown
# STT Runner
|
|
|
|
Speech-to-Text transcription using sherpa-onnx + Qwen3-ASR, plus Text-to-Speech with ZipVoice (zero-shot voice cloning).
|
|
|
|
## Installation
|
|
|
|
```bash
|
|
python3 -m venv .venv
|
|
.venv/bin/pip install -r requirements.txt
|
|
```
|
|
|
|
## Usage
|
|
|
|
### Speech-to-Text
|
|
|
|
```bash
|
|
python stt_runner.py [--language=Indonesian] audio1.wav audio2.wav ...
|
|
```
|
|
|
|
### Text-to-Speech
|
|
|
|
```bash
|
|
python tts_runner.py [--output=out.wav] [--ref-audio=ref.wav] [--ref-text="..."] "text to speak"
|
|
```
|
|
|
|
Output defaults to `output.wav`. The reference audio/text (voice to clone) is set in `config/tts.py` and can be overridden per-run with `--ref-audio` / `--ref-text` (the text must match the audio exactly).
|
|
|
|
## Configuration
|
|
|
|
Model paths and inference parameters are hardcoded in `config/`:
|
|
|
|
- `config/model.py` — model paths (conv_frontend, encoder, decoder, tokenizer under `models/`)
|
|
- `config/asr.py` — inference params: `LANGUAGE`, `HOTWORDS`, `NUM_THREADS`, `PROVIDER`, `SAMPLE_RATE`, `FEATURE_DIM`, `MAX_TOTAL_LEN`, `MAX_NEW_TOKENS`
|
|
- `config/tts.py` — TTS model paths, `REFERENCE_AUDIO`, `REFERENCE_TEXT`, `OUTPUT_FILE`, `NUM_THREADS`, `PROVIDER`, `NUM_STEPS`
|
|
|
|
`LANGUAGE` defaults to `""` (all languages / auto-detect). Passing `--language` on the CLI overrides it.
|
|
|
|
## Download Model (Qwen3-ASR 1.7B int8)
|
|
|
|
```bash
|
|
BASE="https://modelscope.cn/models/zengshuishui/Qwen3-ASR-onnx/resolve/master"
|
|
mkdir -p models/model_1.7B models/tokenizer
|
|
wget -O models/model_1.7B/conv_frontend.onnx "$BASE/model_1.7B/conv_frontend.onnx"
|
|
wget -O models/model_1.7B/encoder.int8.onnx "$BASE/model_1.7B/encoder.int8.onnx"
|
|
wget -O models/model_1.7B/decoder.int8.onnx "$BASE/model_1.7B/decoder.int8.onnx"
|
|
for f in vocab.json merges.txt tokenizer_config.json preprocessor_config.json config.json chat_template.json; do
|
|
wget -O "models/tokenizer/$f" "$BASE/tokenizer/$f"
|
|
done
|
|
```
|
|
|
|
## Download Model (ZipVoice TTS)
|
|
|
|
```bash
|
|
mkdir -p models/zipvoice
|
|
wget -qO- https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/sherpa-onnx-zipvoice-distill-int8-zh-en-emilia.tar.bz2 \
|
|
| tar xjf - -C models/zipvoice --strip-components=1
|
|
wget -O models/zipvoice/vocos_24khz.onnx \
|
|
https://github.com/k2-fsa/sherpa-onnx/releases/download/vocoder-models/vocos_24khz.onnx
|
|
``` |