首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AVSpeechUtterance的最大音量非常安静,速度非常快

AVSpeechUtterance的最大音量非常安静,速度非常快
EN

Stack Overflow用户
提问于 2013-12-09 08:36:06
回答 7查看 4.9K关注 0票数 7

我在我的应用程序中添加语音提示,并在iOS 7中测试AVSpeechUtterance,但默认的语音速率真的很快。最低语音速率更容易理解。但是音量的最大值1太安静了!我在我的iPhone 4上测试了它,音量一直开到最大。一定是出了什么问题,否则这怎么会有用呢?

代码语言:javascript
复制
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];
EN

回答 7

Stack Overflow用户

发布于 2017-02-14 18:28:16

这对我很有效( Swift 3.0 )

代码语言:javascript
复制
let audioSession = AVAudioSession.sharedInstance()  
do {
  try audioSession.setCategory(AVAudioSessionCategoryPlayAndRecord, with: AVAudioSessionCategoryOptions.defaultToSpeaker)  
} catch {   
  print("audioSession properties weren't set because of an error.")   
}
票数 7
EN

Stack Overflow用户

发布于 2015-03-08 10:49:38

@tmr的帖子here为我解决了这个问题:

代码语言:javascript
复制
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord  
                       withOptions:AVAudioSessionCategoryOptionDefaultToSpeaker
                                       error:nil];
票数 4
EN

Stack Overflow用户

发布于 2020-02-24 09:15:55

对于Swift 5,你可以尝试这个(在合成器初始化之前添加它):

代码语言:javascript
复制
        let audioSession = AVAudioSession.sharedInstance()
        try? audioSession.setCategory(AVAudioSession.Category.playAndRecord, mode: AVAudioSession.Mode.default, options: AVAudioSession.CategoryOptions.defaultToSpeaker)
        try? audioSession.setMode(AVAudioSession.Mode.spokenAudio)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20461178

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档