kucing-tts-web / index.html
Suarify's picture
Increase expression tag chip font size by 15 percent
229e185 verified
Raw History Blame Contribute Delete
62.4 kB
<!doctype html>
<html lang="ms"><head><meta charset="utf-8"><title>Kucing TTS by Suarify: lightweight Malay (Bahasa Melayu) text-to-speech, 8 MB, in your browser</title>
<meta name="description" content="Kucing TTS is a lightweight, compact Malaysian Malay (Bahasa Melayu) text-to-speech model: 3.65M parameters (≈4M), under 10 MB, free and open source (Apache-2.0). Runs in your browser with WebGPU or on one CPU thread. Female and male voices.">
<meta name="keywords" content="kucing tts, malay tts, bahasa melayu text to speech, elena, omar, gary, eda, malaysian voice, browser tts, onnx tts, suarify">
<meta property="og:title" content="Kucing TTS: lightweight Malay text-to-speech (under 10 MB)"><meta property="og:description" content="compact Malaysian Malay TTS in 8.5 MB. Runs in your browser. By Suarify (suarify.my).">
<script type="application/ld+json">{"@context":"https://schema.org","@type":"SoftwareApplication","name":"Kucing TTS","applicationCategory":"MultimediaApplication","operatingSystem":"Any (web browser)","description":"Lightweight compact Malaysian Malay (Bahasa Melayu) text-to-speech model, 3.65M parameters (≈4M), 8.5 MB.","license":"https://www.apache.org/licenses/LICENSE-2.0","author":{"@type":"Organization","name":"Suarify","url":"https://suarify.my"},"offers":{"@type":"Offer","price":"0","priceCurrency":"MYR"}}</script>
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;600;700;800&family=Nunito:wght@400;600;700;800&family=Quicksand:wght@500;600;700&display=swap" rel="stylesheet">
<style>
.exppanel{margin:10px 0 0;padding:12px;border:1px solid #cfeae6;border-radius:14px;background:#eaf7f5}
.exppanel[hidden]{display:none}
.exppanel .exptags{display:flex;flex-wrap:wrap;gap:6px}
.exppanel .exptags button{background:#fff;border:1px solid #cfeae6;color:var(--teal-d);border-radius:99px;padding:6px 12px;font:600 14px 'Kemplu','Nunito',sans-serif;cursor:pointer}
.exppanel .exptags button:hover{background:#dff3f0}
.exppanel p{margin:8px 0 0}
</style>
<script type="importmap">{"imports":{"@huggingface/transformers":"https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.8.1"}}</script>
<style>
@font-face{font-family:'Kemplu';src:url('./fonts/Kemplu-W11G.otf') format('opentype');font-display:swap}
:root{--navy:#123f4d;--navy2:#1c6b70;--teal:#2b9b95;--teal-d:#16756f;--tint:#e7f7f5;--ink:#173b45;--mut:#6b8b91;--line:#d7ecea;--bg:#ffffff;--card:#ffffff}
*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{margin:0;background:#ffffff url('./brush.svg') no-repeat fixed center top;background-size:cover;color:var(--ink);font:16px/1.55 'Nunito',system-ui,sans-serif;position:relative}
header{background:#ffffff;color:var(--ink);padding:26px 16px 56px;position:relative;overflow:hidden}
.wrap{max-width:860px;margin:0 auto}
.brand{display:flex;align-items:center;gap:14px}
.badge{display:none}
.badge img{width:40px;height:auto;display:block}
.brand-cat{width:auto;height:150px;object-fit:contain;flex:none}
h1{font:600 clamp(24px,4.4vw,34px)/1.05 'Kemplu','Nunito',sans-serif;margin:0;letter-spacing:-.02em}
.cta{background:linear-gradient(135deg,var(--navy),var(--navy2));color:#fff;border:0}.cta h2{color:#fff}.cta p{color:#cfe3ee;margin:6px 0 14px}.cta a.btn{display:inline-block;background:var(--teal);color:#fff;text-decoration:none;font:600 16px 'Kemplu','Nunito',sans-serif;padding:11px 22px;border-radius:12px}.cta a.btn:hover{background:#27b3b3}
.by{font:600 13px 'Kemplu','Nunito',sans-serif;letter-spacing:.14em;text-transform:uppercase;color:#7fd6d6;margin-top:4px}
.lead{margin:10px 0 0;color:#4d6b73;max-width:640px;font-size:13px;line-height:1.45}
.voice-row input[type=range]{accent-color:var(--teal)}
.voice-row output{font-family:'Kemplu','Nunito',sans-serif;font-weight:800;color:var(--teal-d);min-width:64px;display:inline-block}
#theme{display:none!important}
.bench{margin-top:26px}
.bench table{border-collapse:collapse;width:100%;font-size:12.5px;margin-top:8px}
.bench th,.bench td{text-align:left;padding:6px 10px;border-top:1px solid #22384a}
.bench th{color:#9db1bf;font-weight:600;border-top:0}
.bench .win{color:#2fb8b8;font-weight:700}
.bench .na{color:#9db1bf;font-size:11.5px;margin-top:10px}
main{margin:0 auto;padding:8px 16px 40px;max-width:892px}
.card{background:#ffffff;border:1px solid var(--line);border-radius:22px;padding:18px;box-shadow:0 10px 30px rgba(28,107,112,.08);margin-bottom:14px}
.card h2{font-family:'Kemplu','Nunito',sans-serif;font-weight:600;font:600 16px 'Kemplu','Nunito',sans-serif;margin:0 0 10px;letter-spacing:-.01em;color:var(--navy)}
.spk{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:10px}
.spk button{text-align:left;border:2px solid var(--line);background:#fff;border-radius:12px;padding:12px 14px;cursor:pointer;font:inherit;color:inherit;transition:.15s}
.spk button b{font-family:'Kemplu','Nunito',sans-serif;font-weight:600;display:block;font:600 18px 'Kemplu','Nunito',sans-serif;color:var(--navy)}
.spk button span{color:var(--mut);font-size:13px}
.spk button.on{border-color:var(--teal);background:var(--tint)}
.spk button.on b{color:var(--teal-d)}
.spk-divider{grid-column:1/-1;display:flex;align-items:center;gap:10px;margin:8px 0 2px;color:#6b8b91;font:700 12px 'Nunito',sans-serif;letter-spacing:.12em;text-transform:uppercase}
.spk-divider:after{content:'';flex:1;height:1px;background:#d7ecea}
.spk-divider.exp{color:var(--teal-d)}
.spk-divider.exp:after{background:#cfeae6}
textarea{width:100%;font:inherit;padding:12px;border:2px solid var(--line);border-radius:12px;background:#fff;color:inherit;resize:vertical}
textarea:focus,select:focus,button:focus-visible{outline:3px solid rgba(31,154,154,.35);border-color:var(--teal)}
.row{display:flex;gap:10px;flex-wrap:wrap;align-items:center;margin:12px 0 0}
.chips{margin-top:10px}.chips button{font-size:13px;padding:4px 11px;border-radius:99px;border:1px solid var(--line);background:#fff;color:var(--navy);cursor:pointer}
.chips button:hover{border-color:var(--teal);color:var(--teal-d)}
.chips button.exchip{font-size:15px}
button.go{background:var(--teal);color:#fff;border:0;border-radius:12px;padding:12px 26px;font:600 16px 'Kemplu','Nunito',sans-serif;cursor:pointer;box-shadow:0 4px 14px rgba(31,154,154,.35)}
button.go:hover:not(:disabled){background:var(--teal-d)}button:disabled{opacity:.55;cursor:default}
button.sec{background:#fff;color:var(--navy);border:2px solid var(--line);border-radius:10px;padding:8px 14px;font:600 14px 'Nunito',sans-serif;cursor:pointer}
button.sec:hover{border-color:var(--teal)}
select{font:inherit;font-size:14px;padding:7px 10px;border:2px solid var(--line);border-radius:10px;background:#fff;color:inherit}
label.m{color:var(--mut);font-size:13px;display:flex;align-items:center;gap:6px}
input[type=range]{accent-color:var(--teal);width:140px}
.info{color:var(--mut);font-size:13px;margin:12px 0 0;min-height:1.4em}
code{font-size:12px;word-break:break-all;color:var(--mut)}
details summary{font-family:'Kemplu','Nunito',sans-serif;cursor:pointer;font:600 16px 'Kemplu','Nunito',sans-serif;color:var(--navy);list-style:none;display:flex;align-items:center;gap:8px}
details summary::before{content:"+";display:grid;place-items:center;width:22px;height:22px;border-radius:50%;background:var(--tint);color:var(--teal-d);font-weight:800}
details[open] summary::before{content:"\2212"}
.fx{display:grid;grid-template-columns:repeat(auto-fit,minmax(250px,1fr));gap:4px 22px;margin-top:12px}
.fx .r{display:grid;grid-template-columns:100px 1fr 42px;gap:8px;align-items:center;font-size:13px;color:var(--mut)}
.fx .r input{width:100%}.fx .r output{text-align:right;font-variant-numeric:tabular-nums}
.fx h3{grid-column:1/-1;margin:10px 0 0;font:700 12px Baloo 2,'Nunito',sans-serif;letter-spacing:.1em;text-transform:uppercase;color:var(--teal-d)}
/* --- live speed highlight --- */
/* --- live render stats + waveform --- */
.stats{display:grid;grid-template-columns:1.35fr repeat(4,1fr);gap:10px 14px;background:linear-gradient(100deg,var(--tint),transparent);border:1px solid var(--line);border-radius:14px;padding:13px 15px 11px;margin:0 0 10px}
.stat{display:flex;flex-direction:column;gap:3px;min-width:0}
.stat .lbl{font:700 9.5px Baloo 2,'Nunito',sans-serif;letter-spacing:.13em;color:var(--mut);text-transform:uppercase;white-space:nowrap}
.stat .big{font:800 27px/1.05 Baloo 2,'Nunito',sans-serif;color:var(--teal-d);font-variant-numeric:tabular-nums;letter-spacing:-.035em}
.stat .big.sm{font-size:17px;color:var(--navy);letter-spacing:-.01em}
.stat .sub{font-size:11px;color:var(--teal-d);font-weight:700;white-space:nowrap}
.stats .bar{grid-column:1/-1;height:5px;background:var(--line);border-radius:99px;overflow:hidden;margin-top:2px}
.stats .bar i{display:block;height:100%;width:50%;background:linear-gradient(90deg,var(--teal),#5fd6d6);border-radius:99px;transition:width .45s ease}
.wave{width:100%;height:92px;display:block;border:1px solid var(--line);border-radius:12px;background:var(--bg);margin:0 0 12px}
html[data-never-used=dark] .stat .big.sm{color:#dcebf4}
@media(max-width:620px){.stats{grid-template-columns:1fr 1fr}.stat .big{font-size:24px}}
/* v6: gentle SVG motion + footer gradient separator */
@keyframes floaty{0%,100%{transform:translateY(0) rotate(0)}50%{transform:translateY(-6px) rotate(.6deg)}}
.edge figure:first-child svg{animation:floaty 3.2s ease-in-out infinite}
.edge figure:last-child svg{animation:floaty 3.8s ease-in-out infinite .5s}
@media(prefers-reduced-motion:reduce){.edge figure svg{animation:none}}
footer{position:relative;background:linear-gradient(180deg,var(--tint),transparent);padding:22px 16px 40px;border-radius:0 0 16px 16px}
footer::before{content:"";position:absolute;top:0;left:0;right:0;height:3px;background:linear-gradient(90deg,var(--teal),var(--navy2),var(--teal))}
footer::after{content:"";position:absolute;bottom:0;left:0;right:0;height:4px;background:linear-gradient(135deg,var(--navy),var(--teal))}
footer{max-width:860px;margin:0 auto;color:var(--mut);font-size:13px}
footer a{color:var(--teal-d)}
/* --- language + theme toggles --- */
.headrow,.lead,.spec{position:relative;z-index:2}
.spec{display:flex;flex-wrap:wrap;gap:6px;margin:10px 0 0;color:var(--teal-d);font-size:12.5px;font-weight:700}
.spec span{background:#eaf7f5;border:1px solid #cfeae6;border-radius:99px;padding:3px 10px}
.headrow{display:flex;align-items:center;gap:12px}
.brand{flex:1}
.topbar{display:flex;gap:8px;flex:none}
.tg{background:#eaf7f5;border:1px solid #cfeae6;color:var(--teal-d);border-radius:99px;padding:7px 13px;font:600 13px 'Kemplu','Nunito',sans-serif;cursor:pointer;white-space:nowrap}
.tg:hover{background:rgba(255,255,255,.22)}
/* --- dark mode --- */
html[data-never-used=dark]{--bg:#0a141d;--card:#111f2a;--ink:#e7eff5;--mut:#9db1bf;--line:#22384a;--tint:#0f3a40;--teal:#2fb8b8;--teal-d:#5fd6d6}
html[data-never-used=dark] body{background:var(--bg)}
html[data-never-used=dark] .spk button,html[data-never-used=dark] textarea,html[data-never-used=dark] select,
html[data-never-used=dark] .chips button,html[data-never-used=dark] button.sec{background:#0d1a24;color:var(--ink)}
html[data-never-used=dark] .card{box-shadow:0 8px 28px rgba(0,0,0,.45)}
html[data-never-used=dark] .card h2,html[data-never-used=dark] .spk button b,html[data-never-used=dark] details summary{font-family:'Kemplu','Nunito',sans-serif;color:#dcebf4}
html[data-never-used=dark] .spk button.on b{color:var(--teal-d)}
.spk-divider{grid-column:1/-1;display:flex;align-items:center;gap:10px;margin:8px 0 2px;color:#6b8b91;font:700 12px 'Nunito',sans-serif;letter-spacing:.12em;text-transform:uppercase}
.spk-divider:after{content:'';flex:1;height:1px;background:#d7ecea}
.spk-divider.exp{color:var(--teal-d)}
.spk-divider.exp:after{background:#cfeae6}
html[data-never-used=dark] .spk button.on{border-color:var(--teal)}
html[data-never-used=dark] header{background:linear-gradient(135deg,#081826,#0c2b45)}
html[data-never-used=dark] details summary::before{background:#0f3a40}
/* --- keyword cloud --- */
.tags{display:flex;flex-wrap:wrap;gap:8px;margin-top:6px}
.tags span{font-size:12px;color:var(--mut);border:1px solid var(--line);border-radius:99px;padding:4px 10px;background:var(--bg)}
/* --- edge / IoT --- */
.edge{display:grid;grid-template-columns:1fr 1fr;gap:14px;align-items:center;margin-top:6px}
.edge figure{margin:0}
.edge svg{width:100%;height:auto;display:block;border-radius:12px;border:1px solid var(--line)}
.edge figcaption{font-size:12px;color:var(--mut);margin-top:6px;text-align:center}
.edge ul{margin:8px 0 0;padding-left:18px;color:var(--mut);font-size:14px}
.edge ul li{margin:3px 0}
@media(max-width:560px){.spk{grid-template-columns:1fr}.brand-cat{width:auto;height:96px}.badge{display:none}.badge img{width:30px}.edge{grid-template-columns:1fr}.headrow{flex-wrap:nowrap}.topbar{margin-left:auto}.tg{padding:6px 9px;font-size:11px}h1{font-size:22px}}
/* --- v3 tuning --- */
#stats,#wave{display:none}
#stats.on{display:grid}
#wave.on{display:block}
.infobtn{background:rgba(255,255,255,.14);border:1px solid rgba(255,255,255,.3);color:#fff;border-radius:50%;width:21px;height:21px;font:700 12px Baloo 2,sans-serif;cursor:pointer;margin-left:8px;vertical-align:top;line-height:1;padding:0;transform:translateY(-4px)}
.infobtn:hover{background:rgba(255,255,255,.26)}
.modal-wrap{position:fixed;inset:0;background:rgba(4,14,24,.72);z-index:100;display:flex;align-items:center;justify-content:center;padding:20px}
.modal-wrap[hidden]{display:none}
.modal-card{max-width:720px;width:100%;max-height:86vh;overflow:auto;position:relative;margin:0}
.modal-close{position:absolute;top:8px;right:12px;background:transparent;border:0;color:var(--mut);font:700 26px Baloo 2,sans-serif;cursor:pointer;line-height:1}
.modal-close:hover{color:var(--teal-d)}
.seo-hidden{height:.1px!important;opacity:.001!important;overflow:hidden!important;padding:0!important;margin:0!important;border:0!important;box-shadow:none!important}
.cta-row{margin-top:10px;padding-top:12px;border-top:1px solid var(--line);font-size:12.5px;line-height:1.5}
.cta-row a{color:var(--teal-d)}
/* v7: gear icon + tiny status line */
.gear{background:transparent;border:1px solid var(--line);color:var(--mut);border-radius:8px;width:30px;height:30px;font-size:15px;line-height:1;cursor:pointer;display:inline-grid;place-items:center;vertical-align:middle}
.gear:hover{border-color:var(--teal);color:var(--teal-d)}
.micro{font-size:10px!important;line-height:1.35!important;color:var(--mut)!important;margin:4px 0 2px!important;word-break:break-word}
.micro code{font-size:9.5px!important}
/* Kemplu across short UI text and placeholders; long paragraphs stay in Nunito for readability */
textarea,select,button,label.m,.stat .lbl,.stats .sub,.chips button,.tg,.infobtn,output{font-family:'Kemplu','Nunito',sans-serif}
textarea::placeholder,input::placeholder{font-family:'Kemplu','Nunito',sans-serif;color:#9bb3b7;opacity:1}
.spk button span,.info,.lead,.micro{font-family:'Nunito',system-ui,sans-serif}
</style></head><body>
<div id="bot-keywords" style="opacity:0.01;width:0.1px;height:0.2px;overflow:hidden;position:absolute;left:0;top:0;pointer-events:none" aria-hidden="true">
English: Kucing TTS is a small Malay text-to-speech model by Suarify in Malaysia. It reads Bahasa Melayu text and speaks in four soft voices: Elena, Omar, Gary, Eda and Seri. The website files and ONNX model are served by Hugging Face servers; the speech is generated inside your browser with WASM or WebGPU, so your text does not leave your device. The same model can also run on a server if needed. Keywords: kucing tts, malay tts, bahasa melayu text to speech, malaysian voice, suarify, elena, omar, gary, eda, browser tts, onnx tts, small tts, free tts, server tts.
Bahasa Melayu: Kucing TTS ialah model teks-ke-suara Bahasa Melayu yang kecil dan ringan dari Suarify Malaysia. Ia menukar ayat Melayu kepada suara dengan tujuh suara biasa dan tujuh suara ekspresi: Elena, Omar, Gary, Eda, Gita, Arif, Seri dan versi ekspresi setiap suara. Fail dan model disimpan di pelayan Hugging Face, tetapi suara dijana di dalam pelayar anda menggunakan WASM atau WebGPU, jadi teks anda tidak dihantar ke mana-mana. Model yang sama juga boleh dijalankan di pelayan. Kata kunci: kucing tts, tts melayu, teks ke suara, bahasa melayu, suara malaysia, suarify, elena, omar, gary, eda, tts pelayar, onnx, tts percuma, tts pelayan.
Malaysia: Dibina di Malaysia untuk Bahasa Melayu. Suarify (suarify.my) membuat model kecil yang boleh digunakan secara percuma. Ini adalah pertuturan sintetik; sila maklumkan apabila menggunakannya.
</div>
<header><div class="wrap">
<div class="headrow">
<div class="brand"><img class="brand-cat" src="./kucing-logo-2026.png" alt="Kucing TTS"><div class="badge"><img src="./suarify-logo.png" alt="Suarify"></div><div><h1>Kucing TTS <span style="color:#7fd6d6">voices</span></h1><button class="infobtn" id="infoBtn" title="About / Info">&#9432;</button><div class="by" data-i18n="by">by Suarify</div></div></div>
<div class="topbar">
<button class="tg" id="lang" title="Bahasa Melayu / Malay / Malaysia — tukar bahasa / switch language">BM</button>
<button class="tg" id="theme" title="Mod gelap / Dark mode">◐ Dark</button>
</div>
</div>
<p class="spec"><span>≈4M params (3.65M)</span><span>8 MB ONNX / voice</span><span>Browser (WASM / WebGPU)</span><span>Edge devices: Raspberry Pi, kiosk, mini-PC</span><span>Malay · Bahasa Melayu · Malaysia</span><span>No GPU · no data leaves your device</span></p>
<p class="lead" data-i18n="lead">A small, soft Malay text-to-speech from Suarify Malaysia. Seven standard voices and seven expression voices, about 8 MB each. The pages and model come from Hugging Face servers; the speaking happens in your browser (WASM or WebGPU), so your words stay on your device. The same ONNX model can also be run on a server.</p>
</div></header>
<main>
<section class="card"><h2 data-i18n="h1s">1 · Choose a speaker</h2>
<div class="spk" id="spk"></div>
<div class="row voice-row"><label class="m">Suara / Voice <input id="voiceSlider" type="range" min="0" max="3" step="1" value="0"> <output id="voiceOut">Elena</output></label></div>
<div class="row"><label class="m">version <select id="ver"></select></label>
<label class="m">device <select id="dev"><option value="wasm">WASM (CPU, recommended)</option><option value="auto">auto</option><option value="webgpu">WebGPU</option></select></label>
<a class="m" id="card" href="#" target="_blank" rel="noopener" style="color:var(--teal-d)">Model card ↗</a></div>
<p class="info" id="note"></p>
</section>
<section class="card"><h2 data-i18n="h2s">2 · Type Malay text</h2>
<div class="stats" id="stats">
<div class="stat"><span class="lbl">⚡ Render speed</span><span class="big" id="stRt">—</span><span class="sub" id="stCmp"></span></div>
<div class="stat"><span class="lbl" id="lblTime">Time taken</span><span class="big sm" id="stTime">—</span></div>
<div class="stat"><span class="lbl" id="lblFirst">First audio</span><span class="big sm" id="stFirst">—</span></div>
<div class="stat"><span class="lbl">Audio length</span><span class="big sm" id="stLen">—</span></div>
<div class="stat"><span class="lbl">Device</span><span class="big sm" id="stDev">—</span></div>
<div class="bar"><i id="spdbar"></i></div>
</div>
<canvas id="wave" class="wave" width="760" height="92" aria-label="Waveform of the generated speech"></canvas>
<p class="micro" id="info" hidden></p>
<p class="micro" hidden>Phonemes: <code id="ph"></code></p>
<textarea id="t" rows="3">Selamat pagi, boleh saya bantu encik hari ini?</textarea>
<div class="exppanel" id="expPanel" hidden>
<p class="micro"><b>Seri Expression</b> — type a tag in the box, e.g. <code>[sedih]</code> or <code>[ketawa]</code>. Tap a tag to insert it; the example chips below are specific to this voice.</p>
<div class="exptags" id="expTags"></div>
</div>
<div class="chips row" id="chips"></div>
<div class="row">
<label class="m">speed <input id="sp" type="range" min="0.7" max="1.3" step="0.05" value="1"></label>
<label class="m"><input id="st" type="checkbox" checked> stream</label>
<button class="gear" id="fxBtn" title="Effects lab">⚙</button>
</div>
<div class="row">
<button id="go" class="go" disabled>Loading model…</button>
<button id="replay" class="sec" disabled>Replay</button>
</div>
</section>
<section class="card bench"><details><summary>About Kucing TTS</summary><p class="info">Kucing TTS is an independent Suarify Malay TTS series. Compact Malay voices for browser text-to-speech: Elena, Omar, Gary, Eda, Seri, Gita, Arif and Seri Expression (which understands tags like [sedih] and [ketawa]).</p><p class="info">Elena benchmark: Whisper large-v3 on 40 held-out sentences — mean CER 8.43%, median 4.0% (teacher reference: 11.64% / 4.85%). 3.65M parameters, 8.06 MB int8 ONNX, ~24x realtime on 1 CPU thread.</p><p class="info">It is synthetic speech; please say so when you use it. Free to use under Apache-2.0; please credit Suarify (suarify.my).</p><p class="info">Hosting: this is a free static Hugging Face Space — pages and model files are served from a server, but speech generation runs in your browser (WASM recommended, WebGPU optional). A server-side version can use the same ONNX model.</p></details></section>
<div class="modal-wrap" id="fxModal" hidden><section class="card modal-card" id="fxCard"><button class="modal-close" id="fxClose" aria-label="Close">&#215;</button><h2 data-i18n="fxh">Effects lab (optional)</h2>
<p class="info">Shape the voice after it is made: tone, a delayed second layer (doubling / chorus), an echo tail and a small room. Everything runs in your browser, live while it plays. Pick a preset or move the sliders (double-click a slider to reset it).</p>
<div class="row"><select id="pre"></select><button class="sec" id="fxreset">Reset</button><button class="sec" id="dlraw" disabled>Download wav</button><button class="sec" id="dlfx" disabled>Download wav with effects</button></div>
<div class="fx" id="fx"></div>
</section></div>
<div class="modal-wrap" id="edgeModal" hidden><section class="card modal-card" id="edge"><button class="modal-close" id="edgeClose" aria-label="Close">&#215;</button><h2 data-i18n="edgeh">Runs anywhere: edge, IoT, kiosk, vending machine</h2>
<div class="edge">
<figure>
<svg viewBox="0 0 320 240" role="img" aria-label="Kiosk speaking Bahasa Melayu">
<rect width="320" height="240" rx="12" fill="#0f2a44"/>
<rect x="28" y="26" width="264" height="150" rx="10" fill="#123a63" stroke="#2fb8b8" stroke-width="2"/>
<rect x="44" y="42" width="232" height="88" rx="6" fill="#0a2342"/>
<text x="60" y="66" fill="#7fd6d6" font-family="'Nunito',sans-serif" font-size="11">Kucing TTS</text>
<rect x="60" y="76" width="170" height="8" rx="4" fill="#1f9a9a" opacity=".85"/>
<rect x="60" y="92" width="130" height="8" rx="4" fill="#1f9a9a" opacity=".55"/>
<rect x="60" y="108" width="150" height="8" rx="4" fill="#1f9a9a" opacity=".35"/>
<rect x="44" y="140" width="150" height="24" rx="6" fill="#167878"/>
<text x="56" y="157" fill="#fff" font-family="'Nunito',sans-serif" font-size="11">Sentuh untuk mula</text>
<rect x="230" y="140" width="46" height="24" rx="6" fill="#1f9a9a"/>
<text x="241" y="157" fill="#0a2342" font-family="'Nunito',sans-serif" font-size="11" font-weight="700">OK</text>
<path d="M120 182 v18 h80 v-18" fill="none" stroke="#2fb8b8" stroke-width="3"/>
<rect x="96" y="200" width="128" height="10" rx="5" fill="#123a63" stroke="#2fb8b8" stroke-width="2"/>
<g>
<rect x="196" y="18" width="112" height="40" rx="10" fill="#e8f5f5"/>
<path d="M206 58 l8 10 6 -10 z" fill="#e8f5f5"/>
<text x="206" y="36" fill="#0a2342" font-family="'Nunito',sans-serif" font-size="10" font-weight="700">Selamat datang!</text>
<text x="206" y="49" fill="#167878" font-family="'Nunito',sans-serif" font-size="9">Boleh saya bantu?</text>
</g>
</svg>
<figcaption data-i18n="capkiosk">Kiosk: speaks before the screen finishes loading</figcaption>
</figure>
<figure>
<svg viewBox="0 0 320 240" role="img" aria-label="Vending machine speaking Bahasa Melayu">
<rect width="320" height="240" rx="12" fill="#0f2a44"/>
<rect x="86" y="20" width="148" height="196" rx="10" fill="#123a63" stroke="#2fb8b8" stroke-width="2"/>
<rect x="100" y="34" width="86" height="126" rx="6" fill="#0a2342"/>
<g fill="#1f9a9a">
<rect x="108" y="44" width="14" height="20" rx="3" opacity=".85"/><rect x="128" y="44" width="14" height="20" rx="3" opacity=".5"/>
<rect x="148" y="44" width="14" height="20" rx="3" opacity=".7"/><rect x="108" y="72" width="14" height="20" rx="3" opacity=".55"/>
<rect x="128" y="72" width="14" height="20" rx="3" opacity=".9"/><rect x="148" y="72" width="14" height="20" rx="3" opacity=".45"/>
<rect x="108" y="100" width="14" height="20" rx="3" opacity=".7"/><rect x="128" y="100" width="14" height="20" rx="3" opacity=".6"/>
<rect x="148" y="100" width="14" height="20" rx="3" opacity=".8"/><rect x="108" y="128" width="14" height="20" rx="3" opacity=".5"/>
<rect x="128" y="128" width="14" height="20" rx="3" opacity=".75"/><rect x="148" y="128" width="14" height="20" rx="3" opacity=".65"/>
</g>
<rect x="196" y="40" width="26" height="52" rx="4" fill="#0a2342" stroke="#2fb8b8"/>
<circle cx="209" cy="62" r="6" fill="#2fb8b8"/>
<rect x="196" y="100" width="26" height="34" rx="4" fill="#0a2342" stroke="#2fb8b8"/>
<rect x="104" y="170" width="112" height="16" rx="4" fill="#167878"/>
<text x="112" y="182" fill="#fff" font-family="'Nunito',sans-serif" font-size="9">RM 2.50 · Ais Kopi</text>
<rect x="104" y="192" width="112" height="12" rx="3" fill="#0a2342"/>
<g>
<rect x="10" y="34" width="70" height="40" rx="10" fill="#e8f5f5"/>
<path d="M68 74 l10 8 0 -10 z" fill="#e8f5f5"/>
<text x="20" y="52" fill="#0a2342" font-family="'Nunito',sans-serif" font-size="10" font-weight="700">Terima kasih!</text>
<text x="20" y="65" fill="#167878" font-family="'Nunito',sans-serif" font-size="9">Selamat kembali</text>
</g>
</svg>
<figcaption data-i18n="capvend">Vending machine: a receipt that says its lines out loud</figcaption>
</figure>
</div>
<ul>
<li data-i18n="edge1">Under 10 MB of weights: fits a Raspberry Pi, an Android kiosk, a mini-PC or a browser tab.</li>
<li data-i18n="edge2">Runs on one CPU thread — no GPU, no internet, no per-request cost, no audio leaving the device.</li>
<li data-i18n="edge3">Speaks in Bahasa Melayu Malaysia, including the English words Malaysians actually use.</li>
<li data-i18n="edge4">Same ONNX file everywhere: browser (WebGPU/WASM), Python, Node, .NET, Java, or on-device SDKs.</li>
</ul>
</section></div>
<section class="card seo-hidden"><h2 data-i18n="kwh">Keywords</h2>
<p>Kucing TTS: compact Malay text-to-speech in the browser. Voices: Elena (female), Omar (male), Gary (androgynous), Eda, Seri and Gita (soft female).</p>
</section>
</main>
<footer>
<div class="cta-row"><b data-i18n="ctah">Need custom software or an enterprise voice-AI system?</b> <span data-i18n="ctap">Custom voices, on-premise deployment, call-centre agents and integrations for Malaysian businesses. Tell us what you need.</span> Contact Suarify &rarr; <a href="https://suarify.my/contact-form" target="_blank" rel="noopener">suarify.my/contact-form</a></div>
Kucing TTS is open source (Apache-2.0): free to use, but please credit <b>Suarify (suarify.my)</b>. Voices: <a href="https://huggingface.co/Suarify/kucing-tts-elena-0.1" target="_blank" rel="noopener">Elena</a>, <a href="https://huggingface.co/Suarify/kucing-tts-omar-0.1" target="_blank" rel="noopener">Omar</a>, <a href="https://huggingface.co/Suarify/kucing-tts-gary-0.1" target="_blank" rel="noopener">Gary</a>, <a href="https://huggingface.co/Suarify/kucing-tts-eda-0.1" target="_blank" rel="noopener">Eda</a>. Independent Suarify models. It is synthetic speech; please say so when you use it. </footer>
<script type="module">
import { Kucing, SAMPLE_RATE, EXP_REPO, EXP_STYLES, EXP_EVENTS } from './kucing.js';
const $ = (id) => document.getElementById(id);
let tts, lastAudio; // declared early: drawSpeakers()/speedStrip()/resize listener use them before load()
const SPEAKERS = {
elena: { name: 'Elena', sub: 'female voice — calm and clear', card: 'https://huggingface.co/Suarify/kucing-tts-elena-0.1',
note: 'Independent Suarify model.',
versions: [['Suarify/kucing-tts-elena-0.1', 'v0.1 (Elena)']] },
omar: { name: 'Omar', sub: 'male voice — natural male pitch', card: 'https://huggingface.co/Suarify/kucing-tts-omar-0.1',
note: 'Male voice with text-side F0 scaled into the natural male range.',
versions: [['Suarify/kucing-tts-omar-0.1', 'v0.1 (Omar)']] },
gary: { name: 'Gary', sub: 'androgynous voice — light, text-side F0', card: 'https://huggingface.co/Suarify/kucing-tts-gary-0.1',
note: 'Androgynous voice with unscaled text-side F0.',
versions: [['Suarify/kucing-tts-gary-0.1', 'v0.1 (Gary)']] },
eda: { name: 'Eda', sub: 'soft female voice — warm and calm', card: 'https://huggingface.co/Suarify/kucing-tts-eda-0.1',
note: 'Independent Suarify model.',
versions: [['Suarify/kucing-tts-eda-0.1', 'v0.1 (Eda)']] },
gita: { name: 'Gita', sub: 'soft female voice — gentle and clear', card: 'https://huggingface.co/Suarify/kucing-tts-gita-0.1',
note: 'Independent Suarify model.', versions: [['Suarify/kucing-tts-gita-0.1', 'v0.1 (Gita)']] },
gita_expression: { name: 'Gita Expression', sub: 'expressive voice - type [sedih], [ketawa] and more', card: 'https://huggingface.co/Suarify/kucing-tts-gita-expression-0.1',
note: 'Expression tags: [sedih], [gembira], [marah], [takut], [terkejut], [tenang], [keliru], [kecewa], [penat], [ketawa], [hela], [nangis], [tercungap].',
versions: [['Suarify/kucing-tts-gita-expression-0.1', 'v0.1 (Gita Expression)']] },
eda_expression: { name: 'Eda Expression', sub: 'expressive voice - type [sedih], [ketawa] and more', card: 'https://huggingface.co/Suarify/kucing-tts-eda-expression-0.1',
note: 'Expression tags: [sedih], [gembira], [marah], [takut], [terkejut], [tenang], [keliru], [kecewa], [penat], [ketawa], [hela], [nangis], [tercungap].',
versions: [['Suarify/kucing-tts-eda-expression-0.1', 'v0.1 (Eda Expression)']] },
elena_expression: { name: 'Elena Expression', sub: 'expressive voice - type [sedih], [ketawa] and more', card: 'https://huggingface.co/Suarify/kucing-tts-elena-expression-0.1',
note: 'Expression tags: [sedih], [gembira], [marah], [takut], [terkejut], [tenang], [keliru], [kecewa], [penat], [ketawa], [hela], [nangis], [tercungap].',
versions: [['Suarify/kucing-tts-elena-expression-0.1', 'v0.1 (Elena Expression)']] },
arif_expression: { name: 'Arif Expression', sub: 'expressive voice - type [sedih], [ketawa] and more', card: 'https://huggingface.co/Suarify/kucing-tts-arif-expression-0.1',
note: 'Expression tags: [sedih], [gembira], [marah], [takut], [terkejut], [tenang], [keliru], [kecewa], [penat], [ketawa], [hela], [nangis], [tercungap].',
versions: [['Suarify/kucing-tts-arif-expression-0.1', 'v0.1 (Arif Expression)']] },
omar_expression: { name: 'Omar Expression', sub: 'expressive voice - type [sedih], [ketawa] and more', card: 'https://huggingface.co/Suarify/kucing-tts-omar-expression-0.1',
note: 'Expression tags: [sedih], [gembira], [marah], [takut], [terkejut], [tenang], [keliru], [kecewa], [penat], [ketawa], [hela], [nangis], [tercungap].',
versions: [['Suarify/kucing-tts-omar-expression-0.1', 'v0.1 (Omar Expression)']] },
gary_expression: { name: 'Gary Expression', sub: 'expressive voice - type [sedih], [ketawa] and more', card: 'https://huggingface.co/Suarify/kucing-tts-gary-expression-0.1',
note: 'Expression tags: [sedih], [gembira], [marah], [takut], [terkejut], [tenang], [keliru], [kecewa], [penat], [ketawa], [hela], [nangis], [tercungap].',
versions: [['Suarify/kucing-tts-gary-expression-0.1', 'v0.1 (Gary Expression)']] },
arif: { name: 'Arif', sub: 'male voice — natural male pitch', card: 'https://huggingface.co/Suarify/kucing-tts-arif-0.1',
note: 'Independent Suarify male voice, F0 scaled x0.5 into the natural male range.',
versions: [['Suarify/kucing-tts-arif-0.1', 'v0.1 (Arif)']] },
seri: { name: 'Seri', sub: 'soft female voice — clear and bright', card: 'https://huggingface.co/Suarify/kucing-tts-seri-0.1',
note: 'Independent Suarify model.',
versions: [['Suarify/kucing-tts-seri-0.1', 'v0.1 (Seri)']] },
seri_expression: { name: 'Seri Expression', sub: 'expressive voice — understands [sedih], [ketawa] and more', card: 'https://huggingface.co/Suarify/kucing-tts-seri-expression-0.1',
note: 'Seri with expression tags. Type [sedih], [gembira], [marah], [takut], [terkejut], [tenang], [keliru], [kecewa], [penat], or event tags [ketawa], [hela], [nangis], [tercungap] in the text box.',
versions: [['Suarify/kucing-tts-seri-expression-0.1', 'v0.1 (Seri Expression)']] }
};
const qs = new URLSearchParams(location.search);
// ---- speed benchmarks (1 CPU thread, 24 kHz audio) used by the live highlight ----
const SPEED = {
'Suarify/kucing-tts-elena-0.1': {rt: 24, label: 'Elena v0.1', base: 24, baseLabel: 'Elena v0.1'},
'Suarify/kucing-tts-omar-0.1': {rt: 15, label: 'Omar v0.1', base: 15, baseLabel: 'Omar v0.1'},
'Suarify/kucing-tts-gary-0.1': {rt: 14, label: 'Gary v0.1', base: 14, baseLabel: 'Gary v0.1'},
'Suarify/kucing-tts-eda-0.1': {rt: 24, label: 'Eda v0.1', base: 24, baseLabel: 'Eda v0.1'},
'Suarify/kucing-tts-seri-0.1': {rt: 16, label: 'Seri v0.1', base: 16, baseLabel: 'Seri v0.1'},
'Suarify/kucing-tts-gita-0.1': {rt: 19, label: 'Gita v0.1', base: 19, baseLabel: 'Gita v0.1'},
'Suarify/kucing-tts-gita-expression-0.1': {rt: 16, label: 'Gita Expression', base: 16, baseLabel: 'Gita v0.1'},
'Suarify/kucing-tts-eda-expression-0.1': {rt: 16, label: 'Eda Expression', base: 16, baseLabel: 'Eda v0.1'},
'Suarify/kucing-tts-elena-expression-0.1': {rt: 16, label: 'Elena Expression', base: 16, baseLabel: 'Elena v0.1'},
'Suarify/kucing-tts-arif-expression-0.1': {rt: 16, label: 'Arif Expression', base: 16, baseLabel: 'Arif v0.1'},
'Suarify/kucing-tts-omar-expression-0.1': {rt: 16, label: 'Omar Expression', base: 16, baseLabel: 'Omar v0.1'},
'Suarify/kucing-tts-gary-expression-0.1': {rt: 16, label: 'Gary Expression', base: 16, baseLabel: 'Gary v0.1'},
'Suarify/kucing-tts-arif-0.1': {rt: 16, label: 'Arif v0.1', base: 16, baseLabel: 'Arif v0.1'},
'Suarify/kucing-tts-seri-expression-0.1': {rt: 16, label: 'Seri Expression', base: 16, baseLabel: 'Seri v0.1'}
};
function speedStrip(measured, render, first, dev, audiolen, streaming){
const info = SPEED[$('ver').value] || {rt: 21, label: 'this voice', base: 21, baseLabel: 'v0.4.1'};
const rt = measured == null ? info.rt : measured;
const pct = Math.round((rt / info.base - 1) * 100);
$('stRt').textContent = rt.toFixed(1) + '×';
$('stCmp').textContent = (measured == null ? info.label + ' · ' : '') + (pct >= 0 ? '+' : '') + pct + '% vs ' + info.baseLabel;
const fmt = (v) => v == null ? '—' : (v < 1 ? (v * 1000).toFixed(0) + ' ms' : v.toFixed(2) + ' s');
if (streaming) {
$('lblTime').textContent = 'Time to audio'; $('stTime').textContent = fmt(first);
$('lblFirst').textContent = 'Total gen'; $('stFirst').textContent = fmt(render);
} else {
$('lblTime').textContent = 'Time taken'; $('stTime').textContent = fmt(render);
$('lblFirst').textContent = 'First audio'; $('stFirst').textContent = fmt(first);
}
$('stLen').textContent = audiolen == null ? '—' : audiolen.toFixed(1) + ' s';
$('stDev').textContent = dev || (typeof tts !== 'undefined' && tts ? tts.device : 'auto');
$('spdbar').style.width = Math.min(100, Math.round(rt / 40 * 100)) + '%';
}
// --- waveform with a moving playhead ---
let waveRAF = null, waveStart = 0;
function drawWave(audio, progress){
const c = $('wave'); if (!c) return;
const dpr = Math.min(2, window.devicePixelRatio || 1);
const W = c.width = Math.max(1, Math.floor(c.clientWidth * dpr));
const H = c.height = Math.floor(92 * dpr);
const g = c.getContext('2d'), mid = H / 2;
g.clearRect(0, 0, W, H);
g.strokeStyle = 'rgba(120,150,170,.28)'; g.lineWidth = 1;
g.beginPath(); g.moveTo(0, mid); g.lineTo(W, mid); g.stroke();
if (!audio || !audio.length) return;
const col = getComputedStyle(document.documentElement).getPropertyValue('--teal').trim() || '#1f9a9a';
g.strokeStyle = col; g.lineWidth = Math.max(1, dpr * 0.8);
const step = Math.max(1, Math.floor(audio.length / W));
g.beginPath();
for (let px = 0; px < W; px++){
let mn = 1, mx = -1;
for (let k = px * step; k < (px + 1) * step && k < audio.length; k++){ const v = audio[k]; if (v < mn) mn = v; if (v > mx) mx = v; }
if (mn > mx){ mn = 0; mx = 0; }
g.moveTo(px + 0.5, mid - mx * mid * 0.92); g.lineTo(px + 0.5, mid - mn * mid * 0.92);
}
g.stroke();
if (progress != null && progress >= 0){
const x = Math.max(0, Math.min(W, progress * W));
g.strokeStyle = '#ff7a59'; g.lineWidth = Math.max(1.5, dpr * 1.2);
g.beginPath(); g.moveTo(x, 0); g.lineTo(x, H); g.stroke();
}
}
function playhead(){
if (!lastAudio || !AC){ waveRAF = null; return; }
const el = AC.currentTime - waveStart, dur = lastAudio.length / 24000;
if (el < -0.2 || el > dur + 0.2){ drawWave(lastAudio, null); waveRAF = null; return; }
drawWave(lastAudio, Math.max(0, el / dur));
waveRAF = requestAnimationFrame(playhead);
}
function startPlayhead(){ if (waveRAF) cancelAnimationFrame(waveRAF); waveRAF = requestAnimationFrame(playhead); }
window.addEventListener('resize', () => drawWave(lastAudio, null));
let speaker = SPEAKERS[qs.get('speaker')] ? qs.get('speaker') : 'elena';
function drawSpeakers() {
$('spk').innerHTML = '';
const standardKeys = Object.keys(SPEAKERS).filter((k) => !k.endsWith('_expression'));
const expKeys = standardKeys.map((k) => k + '_expression').filter((k) => SPEAKERS[k]);
const keys = [...standardKeys, ...expKeys];
const divider = (label, cls) => {
const d = document.createElement('div'); d.className = 'spk-divider' + (cls ? ' ' + cls : ''); d.textContent = label;
$('spk').appendChild(d);
};
const button = (k) => {
const s = SPEAKERS[k];
const b = document.createElement('button'); b.className = k === speaker ? 'on' : ''; b.innerHTML = `<b>${s.name}</b><span>${s.sub}</span>`;
b.onclick = () => { if (k !== speaker) navigate(k, SPEAKERS[k].versions[0][0]); }; $('spk').appendChild(b);
};
divider('Standard voices', '');
for (const k of standardKeys) button(k);
divider('Expression voices — type [tags]', 'exp');
for (const k of expKeys) button(k);
const s = SPEAKERS[speaker]; $('ver').innerHTML = '';
for (const [id, lab] of s.versions) { const o = document.createElement('option'); o.value = id; o.textContent = lab; $('ver').appendChild(o); }
const qv = qs.get('model'); if (qv && s.versions.some((v) => v[0] === qv)) $('ver').value = qv;
$('card').href = s.card; $('note').textContent = s.note;
const vsl = $('voiceSlider');
if (vsl) { vsl.max = keys.length - 1; vsl.value = Math.max(0, keys.indexOf(speaker));
const out = $('voiceOut'); if (out) out.textContent = s.name;
vsl.oninput = () => { const k = keys[+vsl.value]; if (k && k !== speaker) navigate(k, SPEAKERS[k].versions[0][0]); }; }
if (typeof speedStrip === 'function') speedStrip();
const exp = speaker.endsWith('_expression');
$('expPanel').hidden = !exp;
}
function navigate(spk, model) { // a fresh page, so a failed WebGPU session cannot linger
const u = new URL(location.href); u.searchParams.set('speaker', spk); u.searchParams.set('model', model); u.searchParams.set('device', $('dev').value); location.href = u;
}
drawSpeakers();
const EX = ['Selamat pagi, boleh saya bantu encik hari ini?', 'Jumlah bayaran anda ialah RM1,250.50.', 'Boleh tolong confirm appointment saya pada hari Isnin?',
'Terima kasih kerana menghubungi kami, sila tunggu sebentar.', 'Kod OTP anda ialah 482913.', 'Temu janji tuan dijadualkan pada hari Khamis, pukul empat petang.'];
const EX_EXP = [
'[sedih] Aduh, sedihnya saya dengar berita tu...',
'[keliru] Eh, saya pun tak faham... apa maksud awak tadi?',
'[kecewa] Saya kecewa sangat dengan hasilnya.',
'[marah] Awak jangan buat macam tu lagi!',
'[takut] Eh, saya takut... lampu tu padam tadi.',
'[terkejut] Wah, betul ke? Saya terkejut!',
'[gembira] Wah, seronoknya! Saya gembira sangat!',
'[tenang] Ambil masa, semua akan okay.',
'[penat] Aduh, saya penat... dah lari tadi.'
];
function drawChips() {
const box = $('chips'); box.innerHTML = '';
for (const e of (speaker.endsWith('_expression') ? EX_EXP : EX)) {
const b = document.createElement('button'); b.textContent = e.slice(0, 28) + '…'; b.title = e;
if (speaker.endsWith('_expression')) b.className = 'exchip';
b.onclick = () => { $('t').value = e; if (!$('go').disabled) $('go').click(); }; box.appendChild(b);
}
const tags = $('expTags'); tags.innerHTML = '';
if (!speaker.endsWith('_expression')) return;
for (const t of [...Object.keys(EXP_STYLES), ...EXP_EVENTS]) {
const b = document.createElement('button'); b.className = 'tg'; b.textContent = '[' + t + ']';
b.title = 'Insert [' + t + '] at the cursor';
b.onclick = () => {
const el = $('t'), s = el.selectionStart ?? el.value.length, e = el.selectionEnd ?? s;
const ins = '[' + t + '] ';
el.value = el.value.slice(0, s) + ins + el.value.slice(e);
el.focus(); el.setSelectionRange(s + ins.length, s + ins.length);
};
tags.appendChild(b);
}
}
// Parse [tags] into speech segments + event clips. Styles persist until the next style tag.
function expressionParts(text) {
const out = []; let style = null, buf = '';
const flush = () => { if (buf.trim()) out.push({ type: 'speech', text: buf.trim(), style }); buf = ''; };
const re = /\[([^\]]+)\]/g; let m, last = 0;
while ((m = re.exec(text))) {
buf += text.slice(last, m.index); last = re.lastIndex;
const tag = m[1].trim().toLowerCase();
if (EXP_STYLES[tag]) { flush(); style = tag; }
else if (EXP_EVENTS.includes(tag)) { flush(); out.push({ type: 'event', tag }); }
else buf += m[0];
}
buf += text.slice(last); flush();
return out;
}
async function loadEventClip(name) {
const url = `https://huggingface.co/${$('ver').value}/resolve/main/events/${name}.wav`;
const buf = await (await fetch(url)).arrayBuffer();
const audio = await AC.decodeAudioData(buf);
return audio.getChannelData(0);
}
drawChips();
// ---------------------------------------------------------------- effects chain (same maths as the FX lab)
const FXP = [
['Tone', [['bdG', 'Body dB', -9, 9, .1, 0], ['prG', 'Presence dB', -9, 9, .1, 0], ['aiG', 'Air dB', -9, 9, .1, 0], ['exM', 'Exciter', 0, 1, .01, 0]]],
['Second layer (doubling / chorus)', [['l2G', 'Level', 0, .8, .01, 0], ['l2D', 'Delay ms', 4, 60, .5, 18], ['l2M', 'Wobble ms', 0, 6, .05, 1.5], ['l2R', 'Wobble Hz', .1, 9, .05, .7], ['l2P', 'Pan', -1, 1, .01, .4]]],
['Echo tail', [['ecM', 'Mix', 0, .7, .01, 0], ['ecT', 'Time ms', 40, 500, 1, 120], ['ecF', 'Feedback', 0, .8, .01, .3]]],
['Room', [['rvM', 'Mix', 0, .5, .01, 0], ['rvD', 'Decay s', .2, 2.5, .05, .6]]],
['Output', [['mG', 'Gain dB', -9, 6, .1, 0]]]
];
const FXD = {}; FXP.forEach(([, rows]) => rows.forEach((r) => { FXD[r[0]] = r[5]; }));
const PRESETS = {
'No effects': {}, 'Warm + presence': { bdG: 3, prG: 3, aiG: 2, mG: -1 }, 'Brighter': { prG: 4, aiG: 5, exM: .35 },
'Haas double': { l2G: .45, l2D: 18, l2M: .8, l2R: .6, l2P: .7 }, 'Chorus thick': { l2G: .5, l2D: 24, l2M: 3.5, l2R: .9, l2P: -.5 },
'Drag tail': { ecM: .35, ecT: 140, ecF: .45, l2G: .25, l2D: 35, l2M: 2, l2R: .4 }, 'Small room': { rvM: .22, rvD: .45 },
'Smooth the robot (try)': { bdG: 2, prG: 2.5, aiG: 2, exM: .25, l2G: .35, l2D: 12, l2M: 2.2, l2R: 1.4, l2P: .5, rvM: .12, rvD: .35 }
};
let fp = { ...FXD };
const curve = (d) => { const n = 1024, c = new Float32Array(n), k = 1 + d * 40; for (let i = 0; i < n; i++) { const x = i * 2 / n - 1; c[i] = Math.tanh(k * x) / Math.tanh(k); } return c; };
function mkIR(ctx, sec, decay) {
const n = Math.max(1, Math.floor(ctx.sampleRate * sec)), ir = ctx.createBuffer(2, n, ctx.sampleRate);
for (let c = 0; c < 2; c++) { const d = ir.getChannelData(c); let lp = 0; for (let i = 0; i < n; i++) { const t = i / n; lp += ((Math.random() * 2 - 1) * Math.pow(1 - t, 3) - lp) * .5; d[i] = lp * Math.exp(-3 * t * (1.2 / Math.max(.1, decay))); } }
return ir;
}
function buildFx(ctx) {
const N = {}, bq = (t) => { const b = ctx.createBiquadFilter(); b.type = t; return b; };
N.input = ctx.createGain(); N.bd = bq('peaking'); N.pr = bq('peaking'); N.ai = bq('highshelf');
N.bd.frequency.value = 350; N.bd.Q.value = 1; N.pr.frequency.value = 2800; N.pr.Q.value = 1; N.ai.frequency.value = 7000;
N.input.connect(N.bd); N.bd.connect(N.pr); N.pr.connect(N.ai);
N.exHp = bq('highpass'); N.exHp.frequency.value = 3500; N.exSh = ctx.createWaveShaper(); N.exSh.curve = curve(.4); N.exHp2 = bq('highpass'); N.exHp2.frequency.value = 3500; N.exG = ctx.createGain(); N.exG.gain.value = 0;
N.ai.connect(N.exHp); N.exHp.connect(N.exSh); N.exSh.connect(N.exHp2); N.exHp2.connect(N.exG);
N.mix = ctx.createGain(); N.ai.connect(N.mix); N.exG.connect(N.mix);
N.l2d = ctx.createDelay(.2); N.l2h = bq('highpass'); N.l2h.frequency.value = 300; N.l2l = bq('lowpass'); N.l2l.frequency.value = 9000; N.l2g = ctx.createGain(); N.l2g.gain.value = 0; N.l2p = ctx.createStereoPanner();
N.ai.connect(N.l2d); N.l2d.connect(N.l2h); N.l2h.connect(N.l2l); N.l2l.connect(N.l2g); N.l2g.connect(N.l2p); N.l2p.connect(N.mix);
N.lfo = ctx.createOscillator(); N.lfoG = ctx.createGain(); N.lfo.connect(N.lfoG); N.lfoG.connect(N.l2d.delayTime); N.lfo.start();
N.ecd = ctx.createDelay(1); N.ecl = bq('lowpass'); N.ecl.frequency.value = 3500; N.ecf = ctx.createGain(); N.ecm = ctx.createGain(); N.ecm.gain.value = 0;
N.ai.connect(N.ecd); N.ecd.connect(N.ecl); N.ecl.connect(N.ecf); N.ecf.connect(N.ecd); N.ecl.connect(N.ecm); N.ecm.connect(N.mix);
N.pre = ctx.createDelay(.2); N.pre.delayTime.value = .012; N.rv = ctx.createConvolver(); N.rvl = bq('lowpass'); N.rvl.frequency.value = 7000; N.rvg = ctx.createGain(); N.rvg.gain.value = 0;
N.out = ctx.createGain(); N.lim = ctx.createDynamicsCompressor(); N.lim.threshold.value = -1; N.lim.ratio.value = 20; N.lim.attack.value = .003; N.lim.release.value = .08; N.lim.knee.value = 0;
N.mix.connect(N.pre); N.pre.connect(N.rv); N.rv.connect(N.rvl); N.rvl.connect(N.rvg); N.rvg.connect(N.out); // reverb is a parallel send
N.mix.connect(N.out); N.out.connect(N.lim);
return N;
}
function applyFx(ctx, N, q, instant) {
const t = ctx.currentTime, s = (prm, v) => { if (instant) prm.value = v; else prm.setTargetAtTime(v, t, .02); };
s(N.bd.gain, q.bdG); s(N.pr.gain, q.prG); s(N.ai.gain, q.aiG); s(N.exG.gain, q.exM * 1.5);
s(N.l2g.gain, q.l2G); s(N.l2d.delayTime, q.l2D / 1000 + q.l2M / 2000 + .0005); s(N.lfoG.gain, q.l2M / 2000); N.lfo.frequency.value = q.l2R; s(N.l2p.pan, q.l2P);
N.ecd.delayTime.value = q.ecT / 1000; s(N.ecf.gain, q.ecF); s(N.ecm.gain, q.ecM);
s(N.rvg.gain, q.rvM); if (N.rvD !== q.rvD) { N.rv.buffer = mkIR(ctx, Math.min(4, q.rvD * 1.6), q.rvD); N.rvD = q.rvD; }
s(N.out.gain, Math.pow(10, q.mG / 20));
}
let AC = null, FX = null;
function ensureAudio() {
if (!AC) { AC = new AudioContext({ sampleRate: 24000 }); FX = buildFx(AC); FX.lim.connect(AC.destination); applyFx(AC, FX, fp, true); }
return AC.resume();
}
function playChunk(c, at) {
const buf = AC.createBuffer(1, c.length, 24000); buf.copyToChannel(c, 0);
const src = AC.createBufferSource(); src.buffer = buf; src.connect(FX.input);
const when = Math.max(at, AC.currentTime); src.start(when); return when + c.length / 24000;
}
async function renderFx(audio, q) {
const off = new OfflineAudioContext(1, audio.length + 24000 * 3, 24000), N = buildFx(off); N.lim.connect(off.destination); applyFx(off, N, q, true);
const b = off.createBuffer(1, audio.length, 24000); b.copyToChannel(audio, 0); const s = off.createBufferSource(); s.buffer = b; s.connect(N.input); s.start(); return (await off.startRendering()).getChannelData(0);
}
function wav(audio, sr) {
const b = new ArrayBuffer(44 + audio.length * 2), v = new DataView(b), w = (o, s) => [...s].forEach((c, i) => v.setUint8(o + i, c.charCodeAt(0)));
w(0, 'RIFF'); v.setUint32(4, 36 + audio.length * 2, true); w(8, 'WAVEfmt '); v.setUint32(16, 16, true); v.setUint16(20, 1, true); v.setUint16(22, 1, true); v.setUint32(24, sr, true); v.setUint32(28, sr * 2, true); v.setUint16(32, 2, true); v.setUint16(34, 16, true); w(36, 'data'); v.setUint32(40, audio.length * 2, true);
audio.forEach((x, i) => v.setInt16(44 + i * 2, Math.max(-1, Math.min(1, x)) * 32767, true)); return new Blob([b], { type: 'audio/wav' });
}
function download(blob, name) { const a = document.createElement('a'); a.href = URL.createObjectURL(blob); a.download = name; a.click(); }
// effects UI
const outs = {}, ins = {};
for (const [g, rows] of FXP) {
const h = document.createElement('h3'); h.textContent = g; $('fx').appendChild(h);
for (const [k, lab, lo, hi, st, df] of rows) {
const r = document.createElement('div'); r.className = 'r'; r.innerHTML = `<span>${lab}</span><input type="range" min="${lo}" max="${hi}" step="${st}"><output></output>`;
const i = r.querySelector('input'), o = r.querySelector('output'); ins[k] = i; outs[k] = o;
i.oninput = () => { fp[k] = +i.value; syncFx(false); }; i.ondblclick = () => { fp[k] = df; syncFx(); }; $('fx').appendChild(r);
}
}
function syncFx(setInputs = true) { for (const k in ins) { if (setInputs) ins[k].value = fp[k]; outs[k].textContent = (+fp[k]).toFixed(+fp[k] % 1 ? 1 : 0); } if (AC) applyFx(AC, FX, fp, false); }
for (const n of Object.keys(PRESETS)) { const o = document.createElement('option'); o.textContent = n; $('pre').appendChild(o); }
$('pre').onchange = () => { fp = { ...FXD, ...PRESETS[$('pre').value] }; syncFx(); };
$('fxreset').onclick = () => { fp = { ...FXD }; $('pre').selectedIndex = 0; syncFx(); };
syncFx();
// ---------------------------------------------------------------- model and speaking
async function load() {
$('go').disabled = true; $('go').textContent = 'Loading model…'; $('info').textContent = '';
const t0 = performance.now();
try {
const so = qs.get('opt'); // debugging aid: ?opt=disabled|basic|extended|all
tts = await Kucing.load({ model: $('ver').value, g2pBase: './g2p/', device: $('dev').value, sessionOptions: so ? { graphOptimizationLevel: so } : undefined });
$('info').textContent = `Model ready on ${tts.device} in ${((performance.now() - t0) / 1000).toFixed(1)} s.`;
$('go').textContent = 'Speak'; $('go').disabled = false;
} catch (e) {
if ($('dev').value !== 'wasm') { // WebGPU can fail on some GPUs or inside the embedded frame: retry on the CPU build in a fresh page
$('info').textContent = 'WebGPU did not work here (' + String(e.message || e).slice(0, 90) + '). Switching to CPU (WASM)...';
$('dev').value = 'wasm'; setTimeout(() => navigate(speaker, $('ver').value), 900); return;
}
$('info').textContent = 'Could not load the model: ' + (e.message || e); $('go').textContent = 'Failed';
}
}
$('go').onclick = async () => {
$('go').disabled = true;
await ensureAudio();
const raw = $('t').value;
const items = tts.expressive ? expressionParts(raw) : [{ type: 'speech', text: raw, style: null }];
$('ph').textContent = items.filter((i) => i.type === 'speech').map((i) => tts.phonemize(i.text).join(' | ')).join(' | ');
const t0 = performance.now(); // time ONLY synthesis, not audio-context/FX setup
const speed = +$('sp').value, parts = []; let next = AC.currentTime + 0.06, firstT = null;
for (const it of items) {
if (it.type === 'event') {
const clip = await loadEventClip(it.tag);
const gap = new Float32Array(Math.round(0.12 * SAMPLE_RATE));
parts.push(gap, clip);
next = playChunk(clip, next + 0.12);
continue;
}
if ($('st').checked) {
for await (const c of tts.stream(it.text, { speed, style: it.style })) { next = playChunk(c, next); parts.push(c); if (firstT === null) firstT = (performance.now() - t0) / 1000; }
} else {
const { audio } = await tts.speak(it.text, { speed, style: it.style });
parts.push(audio); firstT = (performance.now() - t0) / 1000;
playChunk(audio, next); next += audio.length / SAMPLE_RATE;
}
}
const n = parts.reduce((a, c) => a + c.length, 0); lastAudio = new Float32Array(n); let o = 0; for (const c of parts) { lastAudio.set(c, o); o += c.length; }
const s = (performance.now() - t0) / 1000, sec = n / 24000;
$('info').textContent = `${$('st').checked ? `first audio after ${firstT.toFixed(2)} s (streaming starts playback sooner; total synthesis is unchanged); ` : ''}${sec.toFixed(2)} s of audio in ${s.toFixed(2)} s on ${tts.device} (${(sec / s).toFixed(1)}x real time).`;
speedStrip(sec / s, s, firstT, tts.device, sec, $('st').checked);
$('stats').classList.add('on'); $('wave').classList.add('on');
waveStart = AC.currentTime + 0.06; drawWave(lastAudio, 0); startPlayhead();
for (const id of ['replay', 'dlraw', 'dlfx']) $(id).disabled = false;
$('go').disabled = false;
};
$('replay').onclick = async () => { if (!lastAudio) return; await ensureAudio(); waveStart = AC.currentTime + 0.03; playChunk(lastAudio, waveStart); startPlayhead(); };
$('dlraw').onclick = () => lastAudio && download(wav(lastAudio, 24000), 'kucing.wav');
$('dlfx').onclick = async () => { if (lastAudio) download(wav(await renderFx(lastAudio, fp), 24000), 'kucing_effects.wav'); };
$('dev').value = qs.get('device') || 'wasm';
$('dev').onchange = $('ver').onchange = () => navigate(speaker, $('ver').value);
window.__kucing = { load, expressionParts, get tts() { return tts; }, get speaker() { return speaker; } };
if (window.self !== window.top) { const a = document.createElement('a'); a.href = 'https://huggingface.co/spaces/Suarify/kucing-tts-web'; a.target = '_blank'; a.rel = 'noopener'; a.textContent = 'Open full page (best for WebGPU) ↗'; a.style.cssText = 'color:var(--teal-d);font-size:13px;margin-left:auto'; $('card').parentNode.appendChild(a); }
// v3: info modal
$('infoBtn').onclick = () => { $('edgeModal').hidden = false; };
$('fxBtn').onclick = () => { $('fxModal').hidden = false; };
$('fxClose').onclick = () => { $('fxModal').hidden = true; };
$('fxModal').onclick = (e) => { if (e.target === $('fxModal')) $('fxModal').hidden = true; };
$('edgeClose').onclick = () => { $('edgeModal').hidden = true; };
$('edgeModal').onclick = (e) => { if (e.target === $('edgeModal')) $('edgeModal').hidden = true; };
document.addEventListener('keydown', (e) => { if (e.key === 'Escape') { $('edgeModal').hidden = true; $('fxModal').hidden = true; } });
load();
</script>
<script>
// ---- language (EN / BM) and dark mode. Stored per browser; ?lang=en|bm and ?theme=dark|light override.
(function () {
const store = {
get(k) { try { return localStorage.getItem(k); } catch (e) { return null; } },
set(k, v) { try { localStorage.setItem(k, v); } catch (e) {} },
};
const D = {
en: {
spec: '≈4M params (3.65M) · 8 MB ONNX per voice · browser (WASM/WebGPU) or edge devices: Raspberry Pi, kiosk, mini-PC · no GPU, no data leaves your device',
by: 'by Suarify',
lead: 'A small, soft Malay text-to-speech from Suarify Malaysia. Seven standard voices and seven expression voices, ≈4M parameters (3.65M) and 8 MB ONNX each. The pages and model come from Hugging Face servers; the speaking happens in your browser (WASM or WebGPU), so your words stay on your device. The same ONNX model can also be run on a server.',
h1s: '1 · Choose a speaker', h2s: '2 · Type Malay text', fxh: 'Effects lab (optional)', hbench: 'Benchmarks',
nbench: 'CER measured 2026-11-17 with Whisper large-v3 on 200 test + 60 held-out sentences; the v0.3.0 weights themselves are still being re-scored, so the numbers shown are from the checkpoint they continue (same text-model scope). Texture and periodicity measured on the same 6 sentences for both voices. No MOS or side-by-side human rating exists for either voice at this date.',
edgeh: 'Runs anywhere: edge, IoT, kiosk, vending machine',
capkiosk: 'Kiosk: speaks before the screen finishes loading',
capvend: 'Vending machine: a receipt that says its lines out loud',
edge1: 'Under 10 MB of weights: fits a Raspberry Pi, an Android kiosk, a mini-PC or a browser tab.',
edge2: 'Runs on one CPU thread — no GPU, no internet, no per-request cost, no audio leaving the device.',
edge3: 'Speaks in Bahasa Melayu Malaysia, including the English words Malaysians actually use.',
edge4: 'Same ONNX file everywhere: browser (WebGPU/WASM), Python, Node, .NET, Java, or on-device SDKs.',
kwh: 'Keywords',
ctah: 'Need custom software or an enterprise voice-AI system?',
ctap: 'Custom voices, on-premise deployment, call-centre agents and integrations for Malaysian businesses. Tell us what you need.',
theme: '◐ Dark',
},
bm: {
spec: '≈4 juta parameter (3.65M) · 8 MB ONNX setiap suara · pelayar (WASM/WebGPU) atau peranti tepi: Raspberry Pi, kiosk, mini-PC · tanpa GPU, data tidak keluar peranti',
by: 'oleh Suarify',
lead: 'Kucing TTS ialah model teks-ke-suara Bahasa Melayu yang kecil dan lembut dari Suarify Malaysia. Tujuh suara biasa dan tujuh suara ekspresi, ≈4 juta parameter (3.65M) dan 8 MB ONNX setiap satu. Halaman dan model datang dari pelayan Hugging Face; suara dijana dalam pelayar anda (WASM atau WebGPU), jadi teks anda kekal di peranti. Model ONNX yang sama juga boleh dijalankan di pelayan.',
h1s: '1 · Pilih suara', h2s: '2 · Taip teks Melayu', fxh: 'Makmal kesan (pilihan)', hbench: 'Penanda aras',
nbench: 'CER diukur 2026-11-17 dengan Whisper large-v3 pada 200 ayat ujian + 60 ayat held-out; pemberat v0.3.0 sendiri masih dinilai semula, jadi angka yang ditunjukkan adalah daripada checkpoint yang diteruskan (skop model teks yang sama). Tekstur dan periodicity diukur pada 6 ayat yang sama untuk kedua-dua suara. Tiada penilaian MOS atau perbandingan manusia pada tarikh ini.',
edgeh: 'Berjalan di mana-mana: edge, IoT, kiosk, mesin layan diri',
capkiosk: 'Kiosk: bercakap sebelum skrin selesai dimuatkan',
capvend: 'Mesin layan diri: resit yang menyebut barisnya dengan lantang',
edge1: 'Berat kurang 10 MB: muat dalam Raspberry Pi, kiosk Android, mini-PC atau tab pelayar.',
edge2: 'Berjalan pada satu teras CPU — tanpa GPU, tanpa internet, tanpa kos setiap permintaan, audio tidak keluar dari peranti.',
edge3: 'Bercakap dalam Bahasa Melayu Malaysia, termasuk perkataan Inggeris yang memang digunakan rakyat Malaysia.',
edge4: 'Fail ONNX yang sama di merata tempat: pelayar (WebGPU/WASM), Python, Node, .NET, Java atau SDK peranti.',
kwh: 'Kata kunci',
ctah: 'Perlukan perisian tersuai atau sistem suara-AI perusahaan?',
ctap: 'Suara tersuai, penggunaan di premis, ejen pusat panggilan dan integrasi untuk perniagaan Malaysia. Beritahu kami keperluan anda.',
theme: '◐ Gelap',
},
};
const qs = new URLSearchParams(location.search);
let lang = qs.get('lang') || store.get('kucing-lang') ||
((navigator.language || '').toLowerCase().startsWith('ms') ? 'bm' : 'en');
if (!D[lang]) lang = 'en';
function applyLang() {
document.documentElement.lang = lang === 'bm' ? 'ms' : 'en';
for (const el of document.querySelectorAll('[data-i18n]')) {
const v = (D[lang] || D.en)[el.dataset.i18n];
if (v) el.textContent = v;
}
const b = document.getElementById('lang');
if (b) { b.textContent = lang === 'en' ? 'BM' : 'EN'; b.title = lang === 'en' ? 'Bahasa Melayu — Malay — Malaysia: tukar ke BM' : 'Switch to English'; }
document.getElementById('theme').textContent = D[lang].theme;
}
const themeBtn = document.getElementById('theme');
function applyTheme(t) {
document.documentElement.dataset.theme = t;
themeBtn.textContent = t === 'dark' ? (lang === 'bm' ? '☀ Cerah' : '☀ Light') : D[lang].theme;
}
let theme = 'light';
applyLang();
applyTheme(theme);
document.getElementById('lang').onclick = () => {
lang = lang === 'en' ? 'bm' : 'en';
store.set('kucing-lang', lang);
applyLang();
applyTheme(theme);
};
themeBtn.onclick = () => {
theme = theme === 'dark' ? 'light' : 'dark';
store.set('kucing-theme', theme);
applyTheme(theme);
};
})();
</script>
</body></html>