0

is there a way to programmatically download a AVSpeechSynthesisVoice not available in the iphone?

I am able to alert the user they don't have the voice, but I get a silly alert that you need to go to settings blablabla but I want to download it programmatically right there, make it easy peasy for the user. is there a way to do this?

  private func requestSpeechRecognizerAuthorization(completion: @escaping (SFSpeechRecognizerAuthorizationStatus) -> Void) {
        let voice = AVSpeechSynthesisVoice(identifier: "com.apple.voice.enhanced.en-IN.Rishi")
        guard voice != nil else {
            DispatchQueue.main.async {
                let alert = UIAlertController(title: "Voice not available", message: "The voice required for this app is not available. Please download it from Settings > Accessibility > Spoken Content > Voices and try again.", preferredStyle: .alert)
                alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
                UIApplication.shared.windows.first?.rootViewController?.present(alert, animated: true, completion: nil)
            }
            return
        }
        
        SFSpeechRecognizer.requestAuthorization { authStatus in
            DispatchQueue.main.async {
                completion(authStatus)
            }
        }
    }
jnpdx
  • 45,847
  • 6
  • 64
  • 94
Nat Serrano
  • 472
  • 1
  • 4
  • 17

1 Answers1

1

Unfortunately, there is no API provided by Apple to download AVSpeechSynthesisVoice programmatically. The only way to download a voice is through the iOS Settings app, as you have mentioned.

mgsulaiman
  • 56
  • 3