Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The ScriptProcessorNode is deprecated. Use AudioWorkletNode instead. #9

Closed
lavrenkov-sketch opened this issue Aug 24, 2021 · 0 comments

Comments

@lavrenkov-sketch
Copy link

error in example if use Google chrome.
`async function init() {
const model = await Vosk.createModel('vosk-model-small-ru-0.15.tar.gz');

const recognizer = new model.KaldiRecognizer();
recognizer.on("result", (message) => {
    console.log(`Result: ${message.result.text}`);
    TTS(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;`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant