The Cognitive Services Speech SDK has no sound on iPhone's Safari, but can play successfully on Mac's Safari. How should this be handled?

jessebo 20 Reputation points
2024-06-11T11:25:35.4866667+00:00

The Cognitive Services Speech SDK has no sound on iPhone's Safari, but can play successfully on Mac's Safari. How should this be handled?
(in react)

const initializeSynthesizer = () => {
    const speechConfig = SpeechSDK.SpeechConfig.fromSubscription(KEY, REGION);
    const audioConfig = SpeechSDK.AudioConfig.fromDefaultSpeakerOutput();
    speechConfig.speechSynthesisVoiceName = "zh-CN-XiaochenNeural";
    const synthesizer = new SpeechSDK.SpeechSynthesizer(speechConfig, audioConfig);
    setSynthesizer(synthesizer);
}
const synthesizeSpeech = () => {
    if (synthesizer) {
        synthesizer.synthesizing = (s, e) => {
            console.log(e.result.privReason)
        };
        synthesizer.speakTextAsync(
            text,
            result => {
                console.log(result)
                if (result.reason === SpeechSDK.ResultReason.SynthesizingAudioCompleted) {
                    console.log('Synthesis completed.');
                 
                } else {
                    console.error('Speech synthesis canceled, ' + result.errorDetails);
                }
            },
            error => {
                console.error('Error synthesizing speech: ', error);
            }
        );
    }
};
Azure AI Speech
Azure AI Speech
An Azure service that integrates speech processing into apps and services.
1,516 questions
{count} votes

Accepted answer
  1. navba-MSFT 19,655 Reputation points Microsoft Employee
    2024-06-12T05:51:20.9366667+00:00

    @jessebo Welcome to Microsoft Q&A Forum, Thank you for posting your query here!

    .

    Plan 1:

    Can you test with speakSsmlAsync instaed of speakTextAsync and check if that helps? I am sharing the sample code below:

    const synthesizeSpeech = () => {
        if (synthesizer) {
            synthesizer.synthesizing = (s, e) => {
                console.log(e.result.privReason)
            };
            let ssml = `<speak version='1.0' xmlns='http://www.w3.org/2001/10/synthesis' xml:lang='en-US'><voice name='zh-CN-XiaochenNeural'>${text}</voice></speak>`;
            synthesizer.speakSsmlAsync(
                ssml,
                result => {
                    console.log(result)
                    if (result.reason === SpeechSDK.ResultReason.SynthesizingAudioCompleted)           
                    {
                        console.log('Synthesis completed.');
                     
                    } else {
                        console.error('Speech synthesis canceled, ' + result.errorDetails);
                    }
                    synthesizer.close();
                },
                error => {
                    console.error('Error synthesizing speech: ', error);
                    synthesizer.close();
                }
            );
        }
    };
    

    .

    More info here.

    .

    .

    Plan 2:

    You can try using this code sample, and check if that gives the audio output on iOS Safari browser.

    .

    Hope this helps. If you have any follow-up questions, please let me know. I would be happy to help.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful