translet / voice /test.html
bllndebrahim's picture
Clean history (free space)
ae033d7
Raw History Blame Contribute Delete
3.01 kB
<!doctype html>
<html lang="ckb" dir="rtl">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Lala Voice Test</title>
<style>
:root { --bg: #f6f5f2; --card: #fff; --text: #1d1d1f; --dim: #6b6b70; --line: #e4e2dc; --accent: #c8102e; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --bg: #0d0d10; --card: #17171c; --text: #f1f1f3; --dim: #9a9aa3; --line: #2a2a31; --accent: #ff3b52; } }
:root[data-theme="dark"] { --bg: #0d0d10; --card: #17171c; --text: #f1f1f3; --dim: #9a9aa3; --line: #2a2a31; --accent: #ff3b52; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: system-ui, sans-serif; }
.wrap { max-width: 640px; margin: 0 auto; padding: 20px 16px; }
textarea { width: 100%; box-sizing: border-box; min-height: 110px; font-size: 20px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--text); font-family: inherit; }
button { margin-top: 12px; font-size: 18px; padding: 12px 20px; border-radius: 12px; border: none; background: var(--accent); color: #fff; cursor: pointer; }
#status { margin-top: 12px; color: var(--dim); }
</style>
<script src="https://cdn.jsdelivr.net/npm/onnxruntime-web@1.22.0/dist/ort.webgpu.min.js"></script>
<script src="kurdish-voice.js?v=6"></script>
</head>
<body>
<div class="wrap">
<h2>🎙️ دەنگی تایبەتی لالا</h2>
<textarea id="t">سڵاو هاوڕێکەم، چۆنی؟ بەخێربێیت بۆ وەرگێڕی لالا. هیوادارم ڕۆژێکی خۆشت هەبێت.</textarea>
<button id="b">▶ بیخوێنەوە</button>
<div id="status"></div>
<audio id="a" controls style="width:100%;margin-top:12px"></audio>
</div>
<script>
const st = document.getElementById('status');
document.getElementById('b').onclick = async () => {
try {
const t0 = performance.now();
if (!LalaVoice.isLoaded()) st.textContent = 'دەنگەکە بار دەکرێت (تەنها جاری یەکەم)...';
await LalaVoice.load();
const t1 = performance.now();
st.textContent = 'دروست دەکرێت...';
const url = await LalaVoice.speakToUrl(document.getElementById('t').value);
const t2 = performance.now();
const a = document.getElementById('a'); a.src = url; a.play().catch(() => {});
st.innerHTML = `✅ دەنگی خۆمان کار دەکات<br>بارکردن: ${((t1 - t0) / 1000).toFixed(1)} چرکە<br>` +
`دروستکردن: ${((t2 - t1) / 1000).toFixed(1)} چرکە<br>کارتی شاشە: ${LalaVoice.usesGpu() ? 'بەڵێ ✅' : 'نەخێر (پرۆسێسەر)'}`;
} catch (e) {
st.innerHTML = '❌ دەنگی خۆمان کار ناکات<br>هۆکار: ' + (e && e.message ? e.message : e) +
'<br>WebAssembly: ' + (typeof WebAssembly !== 'undefined' ? 'هەیە' : 'نییە') +
'<br>WebGPU: ' + (navigator.gpu ? 'هەیە' : 'نییە');
}
};
</script>
</body>
</html>