As a sanity check I installed this framework:
SwiftTTS from https://github.com/renaudjenny/swift-tts
wrapping it in this class:
import Combine
import SwiftTTSCombine
class VoiceSynth: NSObject{
let engine: TTSEngine = SwiftTTSCombine.Engine()
var cancellables = Set<AnyCancellable>()
func sayThis(_ phrase: String){
engine.speak(string: phrase)
}
func isSpeaking(){
engine.isSpeakingPublisher
.sink { isSpeaking in
print("TTS is currently \(isSpeaking ? "speaking" : "not speaking")")
}
.store(in: &cancellables)
}
}
Then initialised the class in the @main with: var voiceSynth = VoiceSynth()
And the app throws:
FactoryInstall Unable to query results, error: 5
Unable to list voice folder
As before.
Thanks
Maz
Post
Replies
Boosts
Views
Activity
Just downloaded Xcode 15.3 Beta then updated the phone to iOS 17.2
When running the simple example based code with all relevant suggestions eg. used Fred, use an @State to keep AVSpeechSynthesiser in scope.
the app still throws:
#FactoryInstall Unable to query results, error: 5
Unable to list voice folder
When the AVSpeechSynthesizer() instance is created in the @main:
I've appended the relevant code snippet of the test class for reference. Although the detail is irrelevant as the class won't create without the errors.
frankusu: what did you do that's different?
If this is still broken Apple really need to fix this.
I tried to use the CreatingACustomSpeechSynthesizer example app to make a work around but that has install issues.
Any new suggestions gladly received.
Thanks all,
Maz
class VoiceControl: NSObject, ObservableObject {
let synthesizer = AVSpeechSynthesizer() // tried the @State var synthesizer = AVSpeechSynthesizer() approach and that failed too
override init() {
super.init()
//AVSpeechSynthesisVoice.speechVoices() // <-- fetch voice dependencies I tried this and it throws: "Unable to list voice folder" at init
}
func askAQuestion (_ theQuestion: String){
// Create an utterance.
let utterance = AVSpeechUtterance(string: "The quick brown fox jumped over the lazy dog.")
// Configure the utterance.
utterance.rate = 0.57
utterance.pitchMultiplier = 0.8
utterance.postUtteranceDelay = 0.2
utterance.volume = 0.8
// Retrieve the Fred voice as it's the one that works for some.
if let voice = AVSpeechSynthesisVoice(identifier: "com.apple.speech.synthesis.voice.Fred"){
utterance.voice = voice
self.synthesizer.speak(utterance)
}
else {
print("Fred's not home man.")
}
} ...