Is there a way to get the Siri voices for NSSpeechSynthesizer
? NSSpeechSynthesizer.availableVoices()
does not list them, but maybe there is an undocumented trick or something?
I've also tried to use AVSpeechSynthesizer
, even tough it should be available on macOS 10.14+, I couldn't get it to read out loud …
I've used a Playground to test this with the following code from NSHipster:
import Cocoa
import AVFoundation
let string = "Hello, World!"
let utterance = AVSpeechUtterance(string: string)
let synthesizer = AVSpeechSynthesizer()
synthesizer.speak(utterance)
Tap each voice to hear a preview. Switching to a new voice will require your iPhone or iPad to download the necessary files to make the swap. You'll see Downloading… with a loading animation on each voice as you select it. Once the download is complete, your device will start using that voice going forward.
Go to Settings > Siri & Search. Tap Language to change the language that Siri uses for requests and responses. Tap Siri Voice to change the voice that Siri speaks.
Choose a voice On your Mac, choose Apple menu > System Preferences, click Accessibility , then click Spoken Content. Click the System Voice pop-up menu, then choose a voice. To adjust how fast the voice speaks, drag the Speaking Rate slider. Click Play to test the voice and speaking rate.
Siri is a personal assistant that communicates using speech synthesis. Starting in iOS 10 and continuing with new features in iOS 11, we base Siri voices on deep learning. The resulting voices are more natural, smoother, and allow Siri's personality to shine through.
I'm not aware of any trick to make the Siri voice available and I'm afraid it's impossible to make it working via public API.
NSSpeechSynthesizer
and AVSpeechSynthesizer
do utilize SpeechSynthesis.framework
(included in the ApplicationServices.framework
).BuildDefaultVoiceList(bool)
checks bundle identifier (via PermitAllVoices
which compares it with com.apple.VoiceOverUtility
, com.apple.VoiceOver
, com.apple.VoiceOverUtilityCacheBuilder
).All the voices are stored in the /System/Library/Speech/Voices
folder. Tried to copy the voice, change Info.plist
values to make it look like another voice, but still not available/working.
How far do you want to go? Do you want to disable SIP, modify framework, preload your stuff, ... Is it worth it?
AVSpeechSynthesizer
on macOSIt works, but it's buggy and you have to kill the service from time to time.
AVSpeechSynthesisVoice.speechVoices().forEach { voice in
print("Name: \(voice.name) Language: \(voice.language) Identifier: \(voice.identifier)")
}
let utterance = AVSpeechUtterance(string: "Ahoj, jak se máš?")
utterance.voice = AVSpeechSynthesisVoice(identifier: "com.apple.speech.synthesis.voice.zuzana.premium")
let synthesizer = AVSpeechSynthesizer()
synthesizer.speak(utterance)
All the following methods (delegate) are called when you call speak(utterance)
and it works as it should:
speechSynthesizer(_:didStart:)
speechSynthesizer(_:willSpeakRangeOfSpeechString:utterance:)
speechSynthesizer(_:didFinish:)
Something's wrong if you get just the speechSynthesizer(_:didCancel:)
method call and you have to kill the speechsynthesisd
process:
kill `pgrep speechsynthesisd`
Then try again, it fixes the issue for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With