Search code examples
iosavspeechsynthesizerphonetics

How to read international phonetics alphabet with AVSpeechSynthesizer


I'm working on an iOS app, and I have some words in phonetics, i want my iPhone say those words.

for example "tʃat" means "chat".

But AVSpeechSynthesizer can't speak it correctly. ʃ is not pronounced.

Did i miss something, do i need a third part or is this possible on iOS ?


Solution

  • AVSpeechSynthesizer doesn't support phonetics, just regular text, like this:

    let string = "Hello, World!"
    let utterance = AVSpeechUtterance(string: string)
    utterance.voice = AVSpeechSynthesisVoice(language: "en-US")
    
    let synthesizer = AVSpeechSynthesizer()
    synthesizer.speakUtterance(utterance)
    

    (code is lifted from http://nshipster.com/avspeechsynthesizer/)

    The parameter to AVSpeechUtterance's init method is:

    string - A string containing text to be spoken.