AVSpeechUtterance maximum volume is very quiet and speed is very fast

I played with adding speech signals to my application and tested AVSpeechUtterance in iOS 7, but the default speech frequency is REALLY fast. The minimum speech speed is much clearer. But the maximum volume value of 1 is equivalent to calm! I tested it on my iPhone 4 and the volume was completely flipped. Something must be wrong, or how it could be used at all.

AVSpeechSynthesizer *synthesizer = [[AVSpeechSynthesizer alloc]init];
            NSString *mystring = [NSString stringWithFormat:@"Talk String Here %@",myObject.name];
            AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:mystring];
            [utterance setRate:AVSpeechUtteranceMinimumSpeechRate];
            [utterance setVolume:1];
            [synthesizer speakUtterance:utterance];
+5
source share
6 answers

@tmr post here resolved this for me:

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord  
                       withOptions:AVAudioSessionCategoryOptionDefaultToSpeaker
                                       error:nil];
+4
source

This worked for me (Swift 3.0)

let audioSession = AVAudioSession.sharedInstance()  
do {
  try audioSession.setCategory(AVAudioSessionCategoryPlayAndRecord, with: AVAudioSessionCategoryOptions.defaultToSpeaker)  
} catch {   
  print("audioSession properties weren't set because of an error.")   
}
+3
source

iOS 8 iOS 9:

AVSpeechUtterance *utterance = [[AVSpeechUtterance alloc] initWithString:utteranceString];
if([iOSVersionDetector isiOS9OrHigher])
    utterance.rate = AVSpeechUtteranceDefaultSpeechRate;
else
    utterance.rate = 0.1f;
0

For Swift 3, do (to fix the volume problem)

let audioSession = AVAudioSession.sharedInstance()
try audioSession.setCategory(AVAudioSessionCategoryPlayAndRecord, with: AVAudioSessionCategoryOptions.defaultToSpeaker)
0
source

My problem was fixed by setting the mode to AVAudioSessionModeDefaultor AVAudioSessionModeSpokenAudio:

let audioSession = AVAudioSession.sharedInstance()
try audioSession.setCategory(AVAudioSessionCategoryPlayAndRecord, with: .defaultToSpeaker)
try audioSession.setMode(AVAudioSessionModeSpokenAudio)
0
source

Speed ​​is simply the value of a float, and constants are provided for convenience. Try using [statement setRate: AVSpeechUtteranceMaximumSpeechRate * .25];

-1
source

All Articles