AVSpeechSynthesizer pulls words out of thin air.

Hi,

I'm working on a project that uses the AVSpeechSynthesizer and AVSpeechUtterance.

I discovered by chance that the AVSpeechSynthesizer automatically completes some words instead of just outputting what it's supposed to.

These are abbreviations for days of the week or months, but not all of them. I don't want either of them automatically completed, but only the specified text. The completion transcends languages.

I have written a short example program for demonstration purposes.

import SwiftUI
import AVFoundation
import Foundation

let synthesizer: AVSpeechSynthesizer = AVSpeechSynthesizer()

struct ContentView: View {
    var body: some View {
        VStack {
            Button {
                utter("mon")
            } label: {
                Text("mon")
            }
            .buttonStyle(.borderedProminent)
            
            Button {
                utter("tue")
            } label: {
                Text("tue")
            }
            .buttonStyle(.borderedProminent)
            
            Button {
                utter("thu")
            } label: {
                Text("thu")
            }
            .buttonStyle(.borderedProminent)
            
            Button {
                utter("feb")
            } label: {
                Text("feb")
            }
            .buttonStyle(.borderedProminent)
            
            Button {
                utter("feb", lang: "de-DE")
            } label: {
                Text("feb DE")
            }
            .buttonStyle(.borderedProminent)
            
            Button {
                utter("wed")
            } label: {
                Text("wed")
            }
            .buttonStyle(.borderedProminent)
        }
        .padding()
    }
    
    private func utter(_ text: String, lang: String = "en-US") {
        let utterance = AVSpeechUtterance(string: text)
        let voice = AVSpeechSynthesisVoice(language: lang)
        
        utterance.voice = voice
        synthesizer.speak(utterance)
    }
   
}

#Preview {
    ContentView()
}

Thank you

Christian

It seems we'll just have to live with the bugs, and Apple isn't offering any fixes. It's the same with deleting files and to try to put them back, that bug is over 10 years old.

The bug report number is FB25051093

Christian

Yes, AVSpeechSynthesizer sometimes interpret the words, which is really annoying.

I filed 5 years ago a problem with synthesizer with all caps words. In some cases, the word was spelled letter by letter.

Here is the content of the bug report dating May 21: FB9036694

Using AVSpeechSynthesizer, I noticed that some works in UPPERCASE are not correctly spoken.

SMALL is correctly pronounced small but WIDTH is pronounced by spelling W-I-D-T-H

Version 12.4 (12D4e) MacOS 10.15.7 (19H524) I reproduced the problem in playground:

var sentence = "Hello everyone. WIDTH. Now the width and height." // the sentence to be told"
let synthesizer = AVSpeechSynthesizer()
let utterance = AVSpeechUtterance(string: sentence)
utterance.voice = AVSpeechSynthesisVoice(
  language: "en-GB"
)
utterance.rate = AVSpeechUtteranceDefaultSpeechRate
synthesizer.speak(utterance)

Hi Claude,

thank you for your answer. I have incorporated your bug report into my example and updated my repository.

I reported a bug that someone else had already found—more than ten years before me. So, I don't have much hope that anything will happen there in the near future.

I’ve also documented a few other bugs on my GitHub.

Christian