Share via

SPXSpeechSynthesizer stopSpeaking() method cannot return immediately on iOS 17

Sam Yu 5 Reputation points
2023-09-19T16:25:00.6166667+00:00

After calling SPXSpeechSynthesizer startSpeakingSsml() to synthesize the speech, while the speech is playing back, and then call stopSpeaking() to stop the speech, stopSpeaking() cannot return immediately on iOS 17. The speech audio can be stopped immediately, but this method will take 10-20 secs to return.

iOS16 and iOS 15 doesn't have this issue.

Below is our sample swift code to illustrate this issue on iOS 17

// below is the code snippet to start text to speech

let speechConfig = try SPXSpeechConfiguration(subscription: key, region: region)
synthesizer = try SPXSpeechSynthesizer(speechConfig)

let ssml = """
<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis"  xmlns:mstts="https://www.w3.org/2001/mstts" xml:lang="en-US">
    <voice name="en-US-JennyNeural">
        <mstts:express-as style="friendly">
            <prosody rate="1.0">
                Hello how are you ?
            </prosody>
        </mstts:express-as>
    </voice>
</speak>
"""

try synthesizer?.startSpeakingSsml(ssml)


Below is the code snippet to stop text to speech

try synthesizer?.stopSpeaking() // this method takes 10-20s to return

We're using MicrosoftCognitiveServicesSpeech-iOS ver 1.32.1

Azure Speech in Foundry Tools

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.