not working but loading WASM

stt
Fabien Benetou 2 years ago
parent 1ce813ebac
commit a6588256fe
  1. 40
      index.html

@ -23,6 +23,8 @@
<!-- still experimenting, see webdav.html -->
<script src='dependencies/webdav.js'></script>
<script type="application/javascript" src="https://cdn.jsdelivr.net/npm/vosk-browser@0.0.5/dist/vosk.js"></script>
<!-- replacing with local copies as CDNs are like unpkg tend to be slow
<script type="module" src="https://unpkg.com/immers-client/dist/destination.bundle.js"></script>
<script src="https://aframe.io/releases/1.3.0/aframe.min.js"></script>
@ -2315,7 +2317,43 @@ consider pick then apply, i.e changeColorLastId() but for next Id
should be cancealable
*/
async function init() {
const model = await Vosk.createModel('https://fabien.benetou.fr/pub/home/future_of_text_demo/engine/../content/vosk-model-small-en-us-0.15.zip');
//const model = await Vosk.createModel('model.tar.gz');
const recognizer = new model.KaldiRecognizer();
recognizer.on("result", (message) => {
console.log(`Result: ${message.result.text}`);
});
recognizer.on("partialresult", (message) => {
console.log(`Partial result: ${message.result.partial}`);
});
const mediaStream = await navigator.mediaDevices.getUserMedia({
video: false,
audio: {
echoCancellation: true,
noiseSuppression: true,
channelCount: 1,
sampleRate: 16000
},
});
const audioContext = new AudioContext();
const recognizerNode = audioContext.createScriptProcessor(4096, 1, 1)
recognizerNode.onaudioprocess = (event) => {
try {
recognizer.acceptWaveform(event.inputBuffer)
} catch (error) {
console.error('acceptWaveform failed', error)
}
}
const source = audioContext.createMediaStreamSource(mediaStream);
source.connect(recognizerNode);
}
window.onload = init;
</script>
<div id="observablehq-key">

Loading…
Cancel
Save