@suarify/kecil-tts
Malay text to speech, fully on your device. No API key, no server.
Choose a preset or move any slider. The generated code at the bottom follows these settings.
Ready - load the model to begin.
From listVoices() - the same speakers and versions as the Hugging Face Space.
Every snippet has a Try it button that runs it and prints the result in the log above.
Loads the default model on first use, streams Malay text, joins the PCM chunks and plays the result - the most common integration.
import { stream, concatFloat32, encodeWav, SAMPLE_RATE } from '@suarify/kecil-tts';
const chunks = [];
for await (const pcm of stream('Selamat pagi, boleh saya bantu?', { voice: 'yati' })) {
chunks.push(pcm);
}
const audio = concatFloat32(chunks);
const wav = encodeWav(audio, SAMPLE_RATE);
new Audio(URL.createObjectURL(new Blob([wav], { type: 'audio/wav' }))).play();
Returns every speaker and published version so you can build voice/version selectors.
import { listVoices, listVersions } from '@suarify/kecil-tts';
const speakers = listVoices();
const yatiVersions = listVersions('yati');
const everyVersion = listVersions();
Saves rendered audio as a .wav file from a browser.
import { speak, downloadWav } from '@suarify/kecil-tts';
const { wav } = await speak('Selamat pagi.');
downloadWav(wav, { filename: 'selamat-pagi.wav' });
Initializes and caches a model instance for repeated synthesis.
import { loadTTS, VOICE_VERSIONS } from '@suarify/kecil-tts';
const tts = await loadTTS({
voice: 'michael',
version: VOICE_VERSIONS.michael[0].id,
progressCallback: (p) => console.log(p.status, p.file),
});
Synthesizes a whole sentence at once and returns Float32 PCM plus a ready WAV.
import { speak } from '@suarify/kecil-tts';
const { audio, sampleRate, wav } = await speak('Selamat pagi.', {
voice: 'nicole', version: 'v0.2 (latest)', speed: 1,
});
Yields audio piece by piece so playback can start before the whole sentence is rendered.
import { stream, SAMPLE_RATE } from '@suarify/kecil-tts';
for await (const pcm of stream('Assalamualaikum, ini ujian.', { voice: 'firdaus' })) {
playChunk(pcm, SAMPLE_RATE);
}
Collects a stream into raw Float32Array PCM without encoding a WAV.
import { speakPCM } from '@suarify/kecil-tts';
const { audio, sampleRate } = await speakPCM('Harganya RM12.50 ya.');
Concatenates PCM chunks and encodes them as 16-bit mono WAV.
import { encodeWav, concatFloat32, SAMPLE_RATE } from '@suarify/kecil-tts';
const audio = concatFloat32([new Float32Array(24000), new Float32Array(12000)]);
const wav = encodeWav(audio, SAMPLE_RATE);
Normalizes Malay text and converts it to phonemes and token ids (the model front end).
import { normalize, createG2P } from '@suarify/kecil-tts';
const text = normalize('Harga RM12.50, 3 hari lepas.');
const g2p = createG2P();
const phonemes = g2p.phonemize(text);
const ids = g2p.tokens(phonemes);
Lower-level model class for direct control of phonemizing, synthesis and streaming.
import { KecilTTS } from '@suarify/kecil-tts';
const tts = await KecilTTS.load({ model: 'Suarify/kecil-tts-yati-v0.5.0' });
const { audio, sampleRate } = await tts.speak('Selamat malam.');
Server-side Node 20+ usage; writes the WAV with node:fs.
import { speak } from '@suarify/kecil-tts';
import { writeFileSync } from 'node:fs';
const { wav } = await speak('Assalamualaikum, selamat pagi.', { voice: 'yati' });
writeFileSync('out.wav', Buffer.from(wav));
Applies the HF Space effect chain - tone, exciter, doubling/chorus, echo, room and limiter - to raw PCM. speak() already applies effects; use speakPCM() when you want to apply them yourself.
import { speakPCM, applyEffects } from '@suarify/kecil-tts';
const { audio, sampleRate } = await speakPCM('Selamat malam.');
const shaped = applyEffects(audio, { sampleRate, effects: { preset: 'Warm + presence' } });
Press Try it to render the snippet and hear it here.
Install the package and call speak. Or use the ONNX model in Python. No API key, no server.
npm i @suarify/kecil-tts
import { speak } from '@suarify/kecil-tts';
const { wav } = await speak('Assalamualaikum, selamat pagi.', { voice: 'yati' });
new Audio(URL.createObjectURL(new Blob([wav], { type: 'audio/wav' }))).play();
# Full runnable Python example (install, synth, WAV, streaming) is in the repo:
# https://github.com/suarify/kecil-tts-js/blob/main/sample/python/kecil_tts_example.py