|
|
|
@ -43,7 +43,7 @@
|
|
|
|
|
<b>Important:</b>
|
|
|
|
|
<ul>
|
|
|
|
|
<li>your browser must support WASM SIMD instructions for this to work</li>
|
|
|
|
|
<li>quantized models are still in experimental stage</li>
|
|
|
|
|
<li>quantized models are still in experimental stage (<a href="https://github.com/ggerganov/ggml/pull/27">more info</a>)</li>
|
|
|
|
|
<li>Firefox cannot load files larger than 256 MB - use Chrome instead</li>
|
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
@ -174,6 +174,12 @@
|
|
|
|
|
<option value="yi">Yiddish</option>
|
|
|
|
|
</select>
|
|
|
|
|
</td>
|
|
|
|
|
<!-- Slider to select number of threads between 1 and 16 -->
|
|
|
|
|
<td>
|
|
|
|
|
Threads:
|
|
|
|
|
<input type="range" id="threads" name="threads" min="1" max="16" value="8" onchange="changeThreads(this.value)" />
|
|
|
|
|
<span id="threads-value">8</span>
|
|
|
|
|
</td>
|
|
|
|
|
<td>
|
|
|
|
|
<button onclick="onProcess(false);">Transcribe</button>
|
|
|
|
|
</td>
|
|
|
|
@ -281,6 +287,8 @@
|
|
|
|
|
document.getElementById('model-whisper-status').innerHTML = 'loaded "' + model_whisper + '"!';
|
|
|
|
|
|
|
|
|
|
printTextarea('storeFS: stored model: ' + fname + ' size: ' + buf.length);
|
|
|
|
|
|
|
|
|
|
document.getElementById('model').innerHTML = 'Model fetched: ' + model_whisper;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function loadFile(event, fname) {
|
|
|
|
@ -384,6 +392,7 @@
|
|
|
|
|
|
|
|
|
|
cbCancel = function() {
|
|
|
|
|
var el;
|
|
|
|
|
|
|
|
|
|
el = document.getElementById('fetch-whisper-tiny-en' ); if (el) el.style.display = 'inline-block';
|
|
|
|
|
el = document.getElementById('fetch-whisper-base-en' ); if (el) el.style.display = 'inline-block';
|
|
|
|
|
el = document.getElementById('fetch-whisper-small-en'); if (el) el.style.display = 'inline-block';
|
|
|
|
@ -391,7 +400,13 @@
|
|
|
|
|
el = document.getElementById('fetch-whisper-base' ); if (el) el.style.display = 'inline-block';
|
|
|
|
|
el = document.getElementById('fetch-whisper-small' ); if (el) el.style.display = 'inline-block';
|
|
|
|
|
|
|
|
|
|
el = document.getElementById('fetch-whisper-large-q4_0'); if (el) el.style.display = 'inline-block';
|
|
|
|
|
el = document.getElementById('fetch-whisper-base-en-q4_0' ); if (el) el.style.display = 'inline-block';
|
|
|
|
|
el = document.getElementById('fetch-whisper-base-q4_0' ); if (el) el.style.display = 'inline-block';
|
|
|
|
|
el = document.getElementById('fetch-whisper-small-en-q4_0' ); if (el) el.style.display = 'inline-block';
|
|
|
|
|
el = document.getElementById('fetch-whisper-small-q4_0' ); if (el) el.style.display = 'inline-block';
|
|
|
|
|
el = document.getElementById('fetch-whisper-medium-en-q4_0'); if (el) el.style.display = 'inline-block';
|
|
|
|
|
el = document.getElementById('fetch-whisper-medium-q4_0' ); if (el) el.style.display = 'inline-block';
|
|
|
|
|
el = document.getElementById('fetch-whisper-large-q4_0' ); if (el) el.style.display = 'inline-block';
|
|
|
|
|
|
|
|
|
|
el = document.getElementById('whisper-file' ); if (el) el.style.display = 'inline-block';
|
|
|
|
|
el = document.getElementById('model-whisper-status' ); if (el) el.innerHTML = '';
|
|
|
|
@ -405,6 +420,7 @@
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
const kMaxAudio_s = 30*60;
|
|
|
|
|
const kMaxRecording_s = 2*60;
|
|
|
|
|
const kSampleRate = 16000;
|
|
|
|
|
|
|
|
|
|
window.AudioContext = window.AudioContext || window.webkitAudioContext;
|
|
|
|
@ -473,7 +489,7 @@
|
|
|
|
|
doRecording = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// record up to kMaxAudio_s seconds of audio from the microphone
|
|
|
|
|
// record up to kMaxRecording_s seconds of audio from the microphone
|
|
|
|
|
// check if doRecording is false every 1000 ms and stop recording if so
|
|
|
|
|
// update progress information
|
|
|
|
|
function startRecording() {
|
|
|
|
@ -529,9 +545,9 @@
|
|
|
|
|
printTextarea('js: audio recorded, size: ' + audio.length);
|
|
|
|
|
|
|
|
|
|
// truncate to first 30 seconds
|
|
|
|
|
if (audio.length > kMaxAudio_s*kSampleRate) {
|
|
|
|
|
audio = audio.slice(0, kMaxAudio_s*kSampleRate);
|
|
|
|
|
printTextarea('js: truncated audio to first ' + kMaxAudio_s + ' seconds');
|
|
|
|
|
if (audio.length > kMaxRecording_s*kSampleRate) {
|
|
|
|
|
audio = audio.slice(0, kMaxRecording_s*kSampleRate);
|
|
|
|
|
printTextarea('js: truncated audio to first ' + kMaxRecording_s + ' seconds');
|
|
|
|
|
}
|
|
|
|
|
setAudio(audio);
|
|
|
|
|
});
|
|
|
|
@ -559,24 +575,31 @@
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
document.getElementById('progress-bar').style.width = (100*(Date.now() - startTime)/1000/kMaxAudio_s) + '%';
|
|
|
|
|
document.getElementById('progress-text').innerHTML = (100*(Date.now() - startTime)/1000/kMaxAudio_s).toFixed(0) + '%';
|
|
|
|
|
document.getElementById('progress-bar').style.width = (100*(Date.now() - startTime)/1000/kMaxRecording_s) + '%';
|
|
|
|
|
document.getElementById('progress-text').innerHTML = (100*(Date.now() - startTime)/1000/kMaxRecording_s).toFixed(0) + '%';
|
|
|
|
|
}, 1000);
|
|
|
|
|
|
|
|
|
|
printTextarea('js: recording ...');
|
|
|
|
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
if (doRecording) {
|
|
|
|
|
printTextarea('js: recording stopped after ' + kMaxAudio_s + ' seconds');
|
|
|
|
|
printTextarea('js: recording stopped after ' + kMaxRecording_s + ' seconds');
|
|
|
|
|
stopRecording();
|
|
|
|
|
}
|
|
|
|
|
}, kMaxAudio_s*1000);
|
|
|
|
|
}, kMaxRecording_s*1000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// transcribe
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
var nthreads = 8;
|
|
|
|
|
|
|
|
|
|
function changeThreads(value) {
|
|
|
|
|
nthreads = value;
|
|
|
|
|
document.getElementById('threads-value').innerHTML = nthreads;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onProcess(translate) {
|
|
|
|
|
if (!instance) {
|
|
|
|
|
instance = Module.init('whisper.bin');
|
|
|
|
@ -603,7 +626,7 @@
|
|
|
|
|
printTextarea('');
|
|
|
|
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
var ret = Module.full_default(instance, audio, document.getElementById('language').value, translate);
|
|
|
|
|
var ret = Module.full_default(instance, audio, document.getElementById('language').value, nthreads, translate);
|
|
|
|
|
console.log('js: full_default returned: ' + ret);
|
|
|
|
|
if (ret) {
|
|
|
|
|
printTextarea("js: whisper returned: " + ret);
|
|
|
|
|