Skip to content

Commit

Permalink
add header to initial audio send (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
brandom-msft authored and BrianMouncer committed Jan 30, 2020
1 parent 1d3f7e5 commit ffe3ca3
Showing 1 changed file with 12 additions and 2 deletions.
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

0 comments on commit ffe3ca3

Please sign in to comment.