Merge commit '1b74e0d'

This commit is contained in:
Gan, Jimmy
2026-07-08 02:29:17 +08:00
3 changed files with 108 additions and 14 deletions
+9 -3
View File
@@ -6,7 +6,8 @@ env.allowLocalModels = false;
let progressCallback = (progress) => {
const status = document.getElementById('status');
if (progress.status === 'progress') {
status.textContent = `Downloading model... ${progress.file}`;
const pct = progress.progress != null ? ` ${Math.round(progress.progress)}%` : '';
status.textContent = `Downloading model... ${progress.file}${pct}`;
} else if (progress.status === 'done') {
status.textContent = 'Model loaded';
}
@@ -28,7 +29,7 @@ let recognition;
let transcriber = null;
let currentModel = null;
const getModelForLanguage = () => 'Xenova/whisper-small';
const getModelForLanguage = (_lang) => 'Xenova/whisper-small';
const bufferToWav = (buffer, sampleRate = 16000) => {
const numOfChan = 1;
@@ -172,7 +173,12 @@ recordBtn.addEventListener('click', async () => {
try {
await navigator.mediaDevices.getUserMedia({ audio: true });
recognition = new webkitSpeechRecognition();
const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
if (!SpeechRecognition) {
status.textContent = 'Speech recognition not supported in this browser';
return;
}
recognition = new SpeechRecognition();
recognition.continuous = true;
recognition.interimResults = true;
recognition.lang = languageSelect.value;