ai-experiment/README.md

59 lines
2.2 KiB
Markdown
Raw Normal View History

2026-09-15 13:50:17 +07:00
# STT Runner
2026-09-18 17:02:51 +07:00
Speech-to-Text transcription using sherpa-onnx + Qwen3-ASR, plus Text-to-Speech with ZipVoice (zero-shot voice cloning).
2026-09-15 13:50:17 +07:00
## Installation
```bash
python3 -m venv .venv
.venv/bin/pip install -r requirements.txt
```
## Usage
2026-09-18 17:02:51 +07:00
### Speech-to-Text
2026-09-15 13:50:17 +07:00
```bash
2026-09-15 14:59:25 +07:00
python stt_runner.py [--language=Indonesian] audio1.wav audio2.wav ...
2026-09-15 13:50:17 +07:00
```
2026-09-18 17:02:51 +07:00
### 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).
2026-09-15 14:59:25 +07:00
## 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`
2026-09-18 17:02:51 +07:00
- `config/tts.py` — TTS model paths, `REFERENCE_AUDIO`, `REFERENCE_TEXT`, `OUTPUT_FILE`, `NUM_THREADS`, `PROVIDER`, `NUM_STEPS`
2026-09-15 14:59:25 +07:00
`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
2026-09-18 17:02:51 +07:00
```
## 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
2026-09-15 14:59:25 +07:00
```