import UIKit
import AVFoundation
class ViewController: UIViewController, AVSpeechSynthesizerDelegate {
let synthesizer = AVSpeechSynthesizer()
override func viewDidLoad() {
super.viewDidLoad()
let utterance = AVSpeechUtterance(string: "Hello World!")
utterance.voice = AVSpeechSynthesisVoice(identifier: "com.apple.ttsbundle.Samantha-compact")
synth.speak(utterance)
let voices = AVSpeechSynthesisVoice.speechVoices()
for voice in voices {
print (voice.identifier)
}
}
}
Works well on my iPad, but does not on my newly acquired iPhone SE (2nd ten).
Here is the error I get:
2020-05-28 10:21:27.101752-0400 TestText2SpeechiPhoneSE[266:4075] Creating client/daemon connection: 4A71F6A7-2A3C-4F62-BEE2-92309141AE4A
2020-05-28 10:21:27.104441-0400 TestText2SpeechiPhoneSE[266:4075] Got the query meta data reply for: com.apple.MobileAsset.MacinTalkVoiceAssets, response: 0
2020-05-28 10:21:27.151140-0400 TestText2SpeechiPhoneSE[266:4075] Consumed extension
…….
com.apple.ttsbundle.Samantha-compact