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];
}
