Closed clehmeier closed 3 years ago
@clehmeier Currently startContinuousRecognitionAsync and stopContinuousRecognitionAsync are not actually awaitable, so I'm very curious how your code does not throw a syntax error on load. (The current plan is to make those and all other ...Async() functions in the SDK awaitable in v2.0). Currently the correct method signature is
startContinuousRecognitionAsync(callback?: () => void, errorCallback?: (error: string) => void)
with the same parameters for stopContinuousRecognitionAsync,
@clehmeier I'm following up on this issue report. do you have some example code that would explain how you are "awaiting" these calls?
Thanks,
@clehmeier there have been a couple of similar issues logged recently that have been fixed by this Pull Request which is now in master, and will be in 1.15 next month.
@BrianMouncer awaiting was a code relict of divers tries to get the code running, sorry glharper is absolutely right - startContinuousRecognitionAsync and stopContinuousRecognitionAsync are not awaitable. Sorry for this confusion.
@glharper thank you for taking care of this. actually i've got the code running (and of course without await... was an act of desperation :-)), but only by executing the initialization procedure with each (re)start. I think this is not wanted and not recommendet and expensive, but otherwise I can not restart it several times.
start() {
// Initialization
this.audioConfig = sdk.AudioConfig.fromDefaultMicrophoneInput();
this.speechConfig = sdk.SpeechConfig.fromSubscription(this.authkey, this.servicelocation);
this.speechConfig.speechRecognitionLanguage = this.language;
this.recognizer = new sdk.SpeechRecognizer(this.speechConfig, this.audioConfig)
this.recognizer.recognizing = this.recognizer.recognized = this.receivedrecognition.bind(this)
this.recognizer.startContinuousRecognitionAsync(
startRecognizer.bind(this),
function (err) {
console.log("stt:" + err);
startRecognizer.bind(this)
}.bind(this))
function startRecognizer() {
this.started.emit(true);
this.recognizing = true;
}
}
stop() {
this.recognizer.stopContinuousRecognitionAsync(
stopRecognizer.bind(this),
function (err) {
console.log("stt:" + err);
stopRecognizer.bind(this)
}.bind(this))
function stopRecognizer() {
this.ended.emit(true);
this.recognizing = false;
}
}
receivedrecognition(s, message) {
const reason = sdk.ResultReason[message.result.reason];
if (reason == "RecognizedSpeech") {
this.value.emit({ text: message.result.text });
this.recognized.emit({ text: message.result.text });
}
}
So for me personally you pushed me the right way and I got the code running. Thank you very much!
Hello to everybody,
thanks for having this great component!
Here is my little Problem:
Is this an expected behaviour or am I doing something wrong? Or Should I use different method to mute/unmute (I have read the diskussion about it...)?
Here is my code:
Angular: 9.1.12 microsoft-cognitiveservices-speech-sdk: 1.14.1
Thank you so much for your help! Christian