From 447962b53af349e9d12709c0166cc41ed6345ad0 Mon Sep 17 00:00:00 2001 From: Glenn Harper <64209257+glharper@users.noreply.github.com> Date: Thu, 24 Feb 2022 11:09:34 -0800 Subject: [PATCH] check for privAudio for SAD mute/volume API (#486) * check for privAudio for SAD mute/volume API * update url-parse, fix syntax issues from community PR --- package.json | 2 +- src/common.speech/SpeechContext.ts | 4 ++-- src/sdk/Audio/SpeakerAudioDestination.ts | 14 ++++++++++---- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index aaa8478..0a80fb1 100644 --- a/package.json +++ b/package.json @@ -108,7 +108,7 @@ "bent": "^7.3.12", "https-proxy-agent": "^4.0.0", "simple-lru-cache": "0.0.2", - "url-parse": "^1.5.6", + "url-parse": "^1.5.10", "uuid": "^8.3.0", "ws": "^7.5.6" }, diff --git a/src/common.speech/SpeechContext.ts b/src/common.speech/SpeechContext.ts index c20f26f..de210a9 100644 --- a/src/common.speech/SpeechContext.ts +++ b/src/common.speech/SpeechContext.ts @@ -49,10 +49,10 @@ export class SpeechContext { format: {} }; } - if (this.privContext.phraseOutput.detailed === undefined) { + if (this.privContext.phraseOutput.detailed === undefined) { this.privContext.phraseOutput.detailed = { options: [] - }, + }; } this.privContext.phraseOutput.format = "Detailed"; this.privContext.phraseOutput.detailed.options.push("PronunciationAssessment"); diff --git a/src/sdk/Audio/SpeakerAudioDestination.ts b/src/sdk/Audio/SpeakerAudioDestination.ts index 6e40d9a..f92a4d4 100644 --- a/src/sdk/Audio/SpeakerAudioDestination.ts +++ b/src/sdk/Audio/SpeakerAudioDestination.ts @@ -174,19 +174,25 @@ export class SpeakerAudioDestination implements IAudioDestination, IPlayer { } public get volume(): number { - return this.privAudio.volume; + return this.privAudio?.volume ?? -1; } public set volume(volume: number) { - this.privAudio.volume = volume; + if (!!this.privAudio) { + this.privAudio.volume = volume; + } } public mute(): void { - this.privAudio.muted = true; + if (!!this.privAudio) { + this.privAudio.muted = true; + } } public unmute(): void { - this.privAudio.muted = false; + if (!!this.privAudio) { + this.privAudio.muted = false; + } } public get isClosed(): boolean {