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];
    }
    
  • 相关阅读:
    echarts数据包坐标拾取工具
    JS 多个条件判断
    js 实现各浏览器全屏
    前端统计使用插件
    JS 随机排序算法
    js中布尔值为false的六种情况
    Mosaic
    单点登录
    JavaScript数据结构和算法
    一个普通函数的冷僻属性(length、caller、arguments、name、[[Scopes]]和[[FunctionLocation]])
  • 原文地址:https://www.cnblogs.com/liuwenqiang/p/12503960.html
Copyright © 2011-2022 走看看