IOS9 AVSpeech University for problems with AVSpeechSynthesizer

AVSpeechUtterance speed does not work the same for iOS 9 and previous versions of the OS. What change should I make so that the sentence is spoken at the same speed. Are there any other changes I need to make for iOS9? Multiplying AVSpeechUtterance.rate by 6.0 seems to work just fine. Thanks!

+8
iphone xcode ios9 avspeechsynthesizer
source share
2 answers

I also see a change after compilation with the new Xcode. Below are my comparisons from old to new speed. Now I have different speed settings if the device is <= iOS8 or> = iOS9.

iOS 8 iOS 9 Very Slow 0 0.42 Slower 0.06 0.5 My Normal 0.15 0.53 Faster 0.23 0.56 
+12
source share

I have come across this question several times. Given the frequency of changes in iOS recently, I set the default baud rate based on the version of iOS in which the user works in AppDelegate.swift , for example:

 // iOS speech synthesis is flakey between 8 and 9, so set default utterance rate based on iOS version if NSProcessInfo().isOperatingSystemAtLeastVersion(NSOperatingSystemVersion(majorVersion: 8, minorVersion: 0, patchVersion: 0)) { NSUserDefaults.standardUserDefaults().setFloat(0.15, forKey: "defaultSpeechRate") if NSProcessInfo().isOperatingSystemAtLeastVersion(NSOperatingSystemVersion(majorVersion: 9, minorVersion: 0, patchVersion: 0)) { NSUserDefaults.standardUserDefaults().setFloat(0.53, forKey: "defaultSpeechRate") } } else { NSUserDefaults.standardUserDefaults().setFloat(0.5, forKey: "defaultSpeechRate") } 

In my settings scene, I added a slider to adjust the speed:

 @IBOutlet var speechRateSlider: UISlider! 

In viewDidLoad I added the following:

  // Set speech rate speechRateSlider.value = NSUserDefaults.standardUserDefaults().floatForKey("defaultSpeechRate") speechRateSlider.maximumValue = 1.0 speechRateSlider.minimumValue = 0.0 speechRateSlider.continuous = true speechRateSlider.addTarget(self, action: "adjustSpeechRate:", forControlEvents: UIControlEvents.ValueChanged) 

I also associated the action with UISlider :

 @IBAction func adjustSpeechRate(sender: AnyObject) { NSUserDefaults.standardUserDefaults().setFloat(speechRateSlider.value, forKey: "defaultSpeechRate") speechRateSlider.setValue(NSUserDefaults.standardUserDefaults().floatForKey("defaultSpeechRate"), animated: true) print(NSUserDefaults.standardUserDefaults().floatForKey("defaultSpeechRate")) } 

Given the unexpected behavior on different devices and many versions of iOS floating around, I decided to take this route, rather than hard code it into my application.

+1
source share

All Articles