我在我的应用程序中添加语音提示,并在iOS 7中测试AVSpeechUtterance,但默认的语音速率真的很快。最低语音速率更容易理解。但是音量的最大值1太安静了!我在我的iPhone 4上测试了它,音量一直开到最大。一定是出了什么问题,否则这怎么会有用呢?
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];发布于 2017-02-14 18:28:16
这对我很有效( 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.")
}发布于 2015-03-08 10:49:38
@tmr的帖子here为我解决了这个问题:
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord
withOptions:AVAudioSessionCategoryOptionDefaultToSpeaker
error:nil];发布于 2020-02-24 09:15:55
对于Swift 5,你可以尝试这个(在合成器初始化之前添加它):
let audioSession = AVAudioSession.sharedInstance()
try? audioSession.setCategory(AVAudioSession.Category.playAndRecord, mode: AVAudioSession.Mode.default, options: AVAudioSession.CategoryOptions.defaultToSpeaker)
try? audioSession.setMode(AVAudioSession.Mode.spokenAudio)https://stackoverflow.com/questions/20461178
复制相似问题