From e692f8cd2fcd8521f66eec461a84891210c2a763 Mon Sep 17 00:00:00 2001 From: "Brandon Miller (ACAI)" Date: Fri, 24 Jan 2020 15:59:18 -0800 Subject: [PATCH] add header to initial audio send --- src/common.speech/DialogServiceAdapter.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/common.speech/DialogServiceAdapter.ts b/src/common.speech/DialogServiceAdapter.ts index 023c9309..3063a8cd 100644 --- a/src/common.speech/DialogServiceAdapter.ts +++ b/src/common.speech/DialogServiceAdapter.ts @@ -500,6 +500,15 @@ export class DialogServiceAdapter extends ServiceRecognizerBase { return deferred.promise(); } + protected sendWaveHeader(connection: IConnection): Promise { + 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 { if (this.privDialogConnectionPromise) { @@ -722,14 +731,14 @@ export class DialogServiceAdapter extends ServiceRecognizerBase { } if (this.terminateMessageLoop) { - return PromiseHelper.fromResult(undefined); + return PromiseHelper.fromError(`Connection to service terminated.`); } this.privConnectionConfigPromise = this.dialogConnectImpl().onSuccessContinueWithPromise((connection: IConnection): Promise => { return this.sendSpeechServiceConfig(connection, this.privDialogRequestSession, this.privRecognizerConfig.SpeechServiceConfig.serialize()) .onSuccessContinueWithPromise((_: boolean) => { return this.sendAgentConfig(connection).onSuccessContinueWith((_: boolean) => { - return connection; + return connection; }); }); }); @@ -744,6 +753,7 @@ export class DialogServiceAdapter extends ServiceRecognizerBase { private sendPreAudioMessages(): void { this.fetchDialogConnection().onSuccessContinueWith((connection: IConnection): void => { this.sendAgentContext(connection); + this.sendWaveHeader(connection); }); }