Closed pgoodbread closed 4 years ago
There is a time limit. You can get around the time limit like this: https://github.com/stephenlb/spoken#continuous-listening-example
Sorry about being not precise enough.
I'm using the library within a vue project and have enabled continuous listening mode.
methods: {
startListening() {
spoken.listen.on.end(this.continueCapture);
spoken.listen.on.error(this.continueCapture);
spoken.listen({ continuous : true })
.then( transcript => {
this.listenedText = this.listenedText + transcript
})
.catch( e => {console.warn(e.message), true } );
},
stopListening() {
spoken.recognition.continuous = false;
spoken.listen.stop();
this.startedListening = false
},
async continueCapture() {
await spoken.delay(300);
if (spoken.recognition.continuous) this.startListening();
}
},
mounted() {
spoken.listen.on.end(this.continueCapture);
spoken.listen.on.error(this.continueCapture);
}
Yet, after a while it just stops listening. Do you have any suggestions? I coul try a plain html file with javascript.
What you suggest may be a good next step. For reference, we have a production live website that is using continuous
successfully here:
This reference example demonstrates a successful implementation of the continuous listening feature.
Hello Stephen,
thank you for your input.
I tried implementing it based on the source code file you suggested, but it still stops for me after a while. I have discovered that it's often after like 2:30min. On the other hand it seems like it has some kind of hiccup if I speak unclearly, or my recording quality is too bad. It suddenly stops and never starts again.
I tried another implementation, dead simple, independently from VueJS. Still having similar problems.
Here is my source code - for any help and suggestions I would be super grateful.
require('spoken');
document.addEventListener('DOMContentLoaded', () => {
spoken.recognition.lang = 'de-DE';
// Listen to Microphone
if (mic == 'off') return;
console.log("loaded")
document.getElementById("start").addEventListener('click', () => {
spoken.listen.on.end(listen);
spoken.listen.on.error(listen);
spoken.listen.on.partial(ts => console.log(ts));
delay(200);
listen();
})
document.getElementById("stop").addEventListener('click', () => {
spoken.listen.on.end(() => {});
spoken.listen.on.error(() => {});
delay(500);
stopCapture();
})
})
async function listen() {
console.log('listen start')
await delay(200);
await spoken
.listen({ continuous: true })
.then(ts => console.log('end of listen => ', ts))
.catch((e) => console.log(e));
}
function delay(duration) {
return new Promise((resolve) => setTimeout(resolve, duration));
}
function stopCapture() {
console.log('stopCapture beginning')
spoken.recognition.continuous = false;
spoken.listen.stop();
console.log('stopCapture end')
}
function writeText(text) {
document.getElementById('text').innerText = text
}
stopCapture()
you should only need to execute spoken.listen.stop();
no need to change the continuous setting. delay()
calls in each addEventListener
are not really doing anything. Okay to remove those.spoken.listen({continuous:true}).then( speech => {
candidate(speech); // <--- UPDATE UI with speech
} ).catch( e => true );
spoken.listen.on.partial(candidate);
Thank you @stephenlb!
I got it to work and therefore will close this issue.
Hi Stephen,
thanks for your great work on this package.
I'm using it to write documents via dictation. I have encountered the problem, that after a while the
spoken.listen()
function seems to automatically stop. No error is thrown.It really hinders me during dictation.
Do you have any idea why this happens?