Text-to-Speech
Transformers.js
ONNX
Malay
style_text_to_speech_2
tts
webgpu
malay
bahasa-melayu
male-voice
tiny
Instructions to use Suarify/kecil-tts-michael-v0.2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers.js
How to use Suarify/kecil-tts-michael-v0.2 with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('text-to-speech', 'Suarify/kecil-tts-michael-v0.2');
Download examples/stream_python.py from Suarify/kecil-tts-michael-v0.2: direct link, hf CLI and curl.
- Browser
- Download file 1.14 kB
-
https://huggingface.co/Suarify/kecil-tts-michael-v0.2/resolve/main/examples/stream_python.py
- Command line
-
hf download hf://Suarify/kecil-tts-michael-v0.2/examples/stream_python.py
-
curl -L -o stream_python.py https://huggingface.co/Suarify/kecil-tts-michael-v0.2/resolve/main/examples/stream_python.py
1.14 kB
| """Streaming example: play each piece of audio as it is synthesised, show time to first audio. | |
| pip install onnxruntime numpy huggingface_hub sounddevice | |
| pip install https://huggingface.co/Suarify/kecil-tts-michael-v0.2/resolve/main/dist/kecil_tts_8m-0.3.0-py3-none-any.whl | |
| """ | |
| import time | |
| import sounddevice as sd | |
| from kecil_tts import SAMPLE_RATE, KecilTTS | |
| TEXT = ('Selamat pagi, boleh saya bantu encik hari ini? Jumlah bayaran akaun anda ialah RM1,250.50. ' | |
| 'Terima kasih kerana menghubungi kami, sila tunggu sebentar.') | |
| tts = KecilTTS.from_pretrained('Suarify/kecil-tts-michael-v0.2') # downloads the 8.5 MB int8 model once | |
| started = time.perf_counter() | |
| first = None | |
| pieces = tts.stream(TEXT) # generator: one float32 array per piece | |
| stream = sd.OutputStream(SAMPLE_RATE, channels=1, dtype='float32') | |
| stream.start() | |
| for chunk in pieces: | |
| if first is None: | |
| first = time.perf_counter() - started | |
| print(f'first audio after {first:.2f} s') | |
| stream.write(chunk) | |
| print(f'total {time.perf_counter() - started:.2f} s, {len(tts.pieces(TEXT))} pieces') | |
| stream.close() | |