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

fire end of stream at turn.end, not at speech.end #7

Merged
merged 8 commits into from
Dec 20, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/common.speech/ServiceRecognizerBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,12 +349,12 @@ export abstract class ServiceRecognizerBase implements IDisposable {
if (!!this.privRecognizer.speechEndDetected) {
this.privRecognizer.speechEndDetected(this.privRecognizer, speechStopEventArgs);
}

break;
case "turn.end":
if (requestSession.isSpeechEnded && this.privRecognizerConfig.isContinuousRecognition) {
Copy link
Member

@zhouwangzw zhouwangzw Dec 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we return EndOfStream result for RecognizeOnceAsync()? The main purpose of EndOfStream is for RecognizeOnceAsync(). If users calls RecognizeOnceAsync() and there is no audio to be processed anymore, EndOfStream is returned as result (Reason is set to Canceled, and then CancellationDetails returns EndOfStream). #Closed

Copy link
Member Author

@fmegen fmegen Dec 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i changed the code to be more consistent with the c++ implementation, i.e., make sure we fire the event in case the stream has ended and we have seen a turn-start message.
in this case, we fire the eof cancel event once.

re-buffering on the audio side is done through the audio-node, so we are not loosing data here, however,
since we are not yet handling the timestamps in the reco messages, it might be that the message come "too early" which means, there is so much data in flight that there will be a subsequent turn.start/end after the current one.
(note: this /should/ only happen for file data since microphone data is streamed in realtime to the service and thus responsed should not be behind the actual audio data)
#Closed

this.cancelRecognitionLocal(requestSession, CancellationReason.EndOfStream, CancellationErrorCode.NoError, undefined, successCallback);
}
break;
case "turn.end":

const sessionStopEventArgs: SessionEventArgs = new SessionEventArgs(requestSession.sessionId);
requestSession.onServiceTurnEndResponse(this.privRecognizerConfig.isContinuousRecognition);
if (!this.privRecognizerConfig.isContinuousRecognition || requestSession.isSpeechEnded) {
Expand Down