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

Fix for missing audio header on dialogConnector #126

Merged
merged 1 commit into from
Jan 28, 2020
Merged
Changes from all commits
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
14 changes: 12 additions & 2 deletions src/common.speech/DialogServiceAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,15 @@ export class DialogServiceAdapter extends ServiceRecognizerBase {
return deferred.promise();
}

protected sendWaveHeader(connection: IConnection): Promise<boolean> {
return connection.send(new SpeechConnectionMessage(
MessageType.Binary,
"audio",
this.privDialogRequestSession.requestId,
null,
this.audioSource.format.header));
}

// Establishes a websocket connection to the end point.
private dialogConnectImpl(isUnAuthorized: boolean = false): Promise<IConnection> {
if (this.privDialogConnectionPromise) {
Expand Down Expand Up @@ -722,14 +731,14 @@ export class DialogServiceAdapter extends ServiceRecognizerBase {
}

if (this.terminateMessageLoop) {
return PromiseHelper.fromResult<IConnection>(undefined);
return PromiseHelper.fromError(`Connection to service terminated.`);
}

this.privConnectionConfigPromise = this.dialogConnectImpl().onSuccessContinueWithPromise((connection: IConnection): Promise<IConnection> => {
return this.sendSpeechServiceConfig(connection, this.privDialogRequestSession, this.privRecognizerConfig.SpeechServiceConfig.serialize())
.onSuccessContinueWithPromise((_: boolean) => {
return this.sendAgentConfig(connection).onSuccessContinueWith((_: boolean) => {
return connection;
return connection;
});
});
});
Expand All @@ -744,6 +753,7 @@ export class DialogServiceAdapter extends ServiceRecognizerBase {
private sendPreAudioMessages(): void {
this.fetchDialogConnection().onSuccessContinueWith((connection: IConnection): void => {
this.sendAgentContext(connection);
this.sendWaveHeader(connection);
});
}

Expand Down