简体   繁体   中英

JS Azure Speech SDK Text to Speech (control volume for AudioConfig)

I'm working with azure text to speech service for enabling voice based outputs. Using Speech SDK Javascript .

For outputing the sound, im creating fromSpeakerOutput instance with custom iPlayer (as in docs ).

const browserSound = new speechsdk.SpeakerAudioDestination();
const audioConfig = speechsdk.AudioConfig.fromSpeakerOutput(browserSound);
var synthesizer = new speechsdk.SpeechSynthesizer(speechConfig, audioConfig);

Issue is, i need some iPlayer customizations like pause, resume, stop current sound. I could see only pause and resume. Is there any way i could cancel current playing sound?

Thanks.

As suggested by glharper ,

Currently, the SpeakerAudioDestination does not expose the volume setting for the underlying HTMLAudioElement , but that will be added in the next version.

You can refer to JS Azure Speech SDK Text to Speech (control volume for AudioConfig and Glharper/volume api speaker audio

Issue is, i need some iPlayer customizations like pause, resume, stop current sound. I could see only pause and resume. Is there any way i could cancel current playing sound?

JavaScript: Added volume getter/setter and mute()/unmute() APIs to SpeakerAudioDestination

 public get volume(): number {
        return this.privAudio.volume;
    }

    public set volume(volume: number) {
        this.privAudio.volume = volume;
    }

    public mute(): void {
        this.privAudio.muted = true;
    }

    public unmute(): void {
        this.privAudio.muted = false;
    }

Reference: Speech SDK 1.20.0: January 2022 release

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM