zoukankan      html  css  js  c++  java
  • iOS 百度导航没有语音播报

    1.百度地图没有语音播报

    可以尝试如下方式:

    1.tts确认相关key正确,可以放入官方demo测试

    2.setting中 Product Name 尝试设置成英文,在info.plist设置Bundle display name为app名称。

    3.可以尝试使用自定义tts方式

    [BNaviService_Instance initNaviService:nil success:^{
                     //导航SDK鉴权
                     [BNaviService_Instance authorizeNaviAppKey:BaiduMapKey
                                                     completion:^(BOOL suc) {
                         NSLog(@"authorizeNaviAppKey ret = %d",suc);
                     }];
                     //TTS SDK鉴权
                     [BNaviService_Instance authorizeTTSAppId:BaiduTTS
                                                       apiKey:TTS_API_KEY
                                                    secretKey:TTS_SECRET_KEY
                                                   completion:^(BOOL suc) {
                         NSLog(@"authorizeTTS ret = %d",suc);
                     }];
                     // 设置BNNaviSoundDelegate 代理
                     [BNaviService_Sound setSoundDelegate:self];
                 } fail:^{
                     NSLog(@"initNaviSDK fail");
                 }];
    #pragma mark - BNNaviSoundDelegate
    - (void)onPlayTTS:(NSString*)text {
        NSLog(@"onPlayTTS text = %@", text);
        BOOL istts = [BNaviService_Sound isTTSPlaying];
        BOOL s = [BNaviService_Sound resume];
        BOOL p = [BNaviService_Sound playText:text];
        //        自定义语音播报
        [self customSound:text];
        NSLog(@"istts:%d,s:%d,p:%d",istts,s,p);
    }
    
    /**
     使用自定义的TTS语音播报
     */
    - (void)customSound:(NSString *)text
    {
        NSLog(@"%@",text);
        //    可以假想成要说的一段话
        AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:text];
        utterance.pitchMultiplier=0.8;
        //中式发音 AVSpeechSynthesisVoice
        AVSpeechSynthesisVoice *voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"zh-CN"];
        //英式发音
        //    AVSpeechSynthesisVoice *voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-GB"];
        utterance.voice = voice;
        NSLog(@"%@",[AVSpeechSynthesisVoice speechVoices]);
        //        语音合成器, 可以假想成一个可以说话的人, 是最主要的接口
        AVSpeechSynthesizer *synth = [[AVSpeechSynthesizer alloc]init];
        [synth speakUtterance:utterance];
    }
    
  • 相关阅读:
    window.open的火狐、谷歌兼容写法
    一个分数怎样约分?想知道的速度了。。。
    这是第二道题内容要求写一个银行的ATM系统 这个浪费了好长时间 ,遇到了许多问题,不过都解决了,上程序
    两个有理数相加(要求输入时以分数形式,输出时也以分数形式)
    linux centos 7.5下 源码编译安装 lua环境
    SecureCRT 6.7 vim高亮
    C#第一章笔记
    HTML5考试错题
    第九章博客
    第八章博客
  • 原文地址:https://www.cnblogs.com/liuwenqiang/p/12503960.html
Copyright © 2011-2022 走看看