Add onnx/model-optimized.onnx: same audio, less time
Browse filesExported from tiny-voca-ar.pt with `tiny_voca.export --optimized`. onnx/model.onnx and the v0.2.0 tag do not change.
Files changed (2)
- README.md+46
- onnx/model-optimized.onnxAdded+3
42 unmodified lines4344454647484 unmodified lines53545556575837 unmodified lines9697989910010142 unmodified lines|---|---|| `tiny-voca-ar.pt` | PyTorch inference checkpoint, float32 || `onnx/model.onnx` | ONNX export, checked against the PyTorch model || `config.json` | Model settings, phoneme inventory, voices || `code/tiny_voca_ar-0.2.0-py3-none-any.whl` | The `tiny_voca` Python package (front end, model, inference) at the commit that trained this model || `samples/` | The audio on this page |4 unmodified lines- `tiny-voca-ar.pt`: `ff6740b2b52f04105277eef21e9e28823cbe80fc00ac65aacbddf09657a06a7c`- `onnx/model.onnx`: `3f065f5ed0d2f7b932dea86dba3de111ad5b1d24b29b3ab34b138fa9c72d6d89`## Samples37 unmodified linesThe model reads the diacritics as written. Text without tashkeel is refused (`needs_tashkeel`). This version hasno diacritizer. Diacritize the text and review it before the model reads it.## EvaluationThe student and its teacher read the same 43 sentences of the fixed eval set (`tiny_voca.evalset`: short,42 unmodified lines434445464748494 unmodified lines5455565758596037 unmodified lines989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614742 unmodified lines|---|---|| `tiny-voca-ar.pt` | PyTorch inference checkpoint, float32 || `onnx/model.onnx` | ONNX export, checked against the PyTorch model || `onnx/model-optimized.onnx` | Faster ONNX export with the same audio (see [ONNX](#onnx)). Added after v0.2.0, so it is on `main` and not in the `v0.2.0` tag || `config.json` | Model settings, phoneme inventory, voices || `code/tiny_voca_ar-0.2.0-py3-none-any.whl` | The `tiny_voca` Python package (front end, model, inference) at the commit that trained this model || `samples/` | The audio on this page |4 unmodified lines- `tiny-voca-ar.pt`: `ff6740b2b52f04105277eef21e9e28823cbe80fc00ac65aacbddf09657a06a7c`- `onnx/model.onnx`: `3f065f5ed0d2f7b932dea86dba3de111ad5b1d24b29b3ab34b138fa9c72d6d89`- `onnx/model-optimized.onnx`: `d4fef7050cdfc63969cae340a7d139652d51b1bcf2bc4973cc66f7076f82fe44`## Samples37 unmodified linesThe model reads the diacritics as written. Text without tashkeel is refused (`needs_tashkeel`). This version hasno diacritizer. Diacritize the text and review it before the model reads it.## ONNX> [!TIP]> Use `onnx/model-optimized.onnx` for speed. It replaces `onnx/model.onnx` with no code change. The inputs, the> outputs, and the audio are the same, up to float rounding.| Time saved on a clip of | Browser (WASM, 1 thread) | CPU, 1 thread | CPU, 4 threads ||---|---:|---:|---:|| 5 s | 7% | 16% | 30% || 10 s | 10% | 25% | 40% || 21 s | 14% | 34% | 51% |Measured against `onnx/model.onnx` on an i7-11800H laptop, with ONNX Runtime 1.32.0 and, in Chrome, ONNX Runtime Web1.20.1. With the same noise signal, 510 renderings have the same durations and differ by at most 1 step in 16-bitaudio. The method is in[docs/eval.md](https://github.com/abodacs/tiny-voca-ar/blob/main/docs/eval.md#optimized-onnx-graph).To run it, install the package as in [Usage](#usage), then:```bashpip install onnxruntimehf download abdullah/tiny-voca-ar-v2 onnx/model-optimized.onnx --local-dir tiny-voca-ar``````pythonimport numpy as npimport onnxruntime as ortimport soundfile as sffrom tiny_voca.text import phonemizesession = ort.InferenceSession("tiny-voca-ar/onnx/model-optimized.onnx", providers=["CPUExecutionProvider"])phones = phonemize("مَرْحَبًا، أَنَا جَاهِزٌ مَتَى شِئْتَ.")number = lambda value: np.array([value], dtype=np.float32)audio, durations = session.run(None, {"tokens": np.array([phones.ids], dtype=np.int64),"stress": np.array([phones.stress], dtype=np.int64),"voice": np.array([1], dtype=np.int64), # 0 = 7001, 1 = 7003"speed": number(1.0), "pitch_shift": number(0.0), "pitch_range": number(1.0),})sf.write("hello.wav", audio[0], 24000)```The graph reads one sentence at a time, at most 512 phonemes.## EvaluationThe student and its teacher read the same 43 sentences of the fixed eval set (`tiny_voca.evalset`: short,
123version https://git-lfs.github.com/spec/v1oid sha256:d4fef7050cdfc63969cae340a7d139652d51b1bcf2bc4973cc66f7076f82fe44size 21362944README.md+46
onnx/model-optimized.onnxAdded+3