改变建议语言并不奏效

时间:2016-01-22 19:31:53

标签: ios swift skmaps

我是Skobbler SDK的新手,并学习了Swift演示+详细记录的tuto(http://developer.skobbler.com/getting-started/ios#sec01

但是,我仍然无法使用他们的说明配置建议语言设置......

这是我的代码:

let settings = SKAdvisorSettings()
    settings.advisorVoice =  "fr"
    settings.language  = SKAdvisorLanguage.FR
    settings.advisorType = SKAdvisorType.AudioFiles
    settings.resourcesPath = NSBundle.mainBundle().resourcePath! + "/SKMaps.bundle/AdvisorConfigs/Languages"

事件由:

定义
 func routingService(routingService: SKRoutingService!, didChangeCurrentAdvice currentAdvice: SKRouteAdvice!, isLastAdvice: Bool) {

    NSLog("New advice "+currentAdvice.adviceInstruction)

}

我得到"在90米右转"例如。

顺便说一句,没有播放任何音频文件

你能帮我一把:)提前谢谢

3 个答案:

答案 0 :(得分:1)

好的,我发现我的错误是替换:

  settings.advisorType = SKAdvisorType.AudioFiles

  settings.advisorType = SKAdvisorType.TextToSpeech

但是我仍然不知道如何使用预先录制的文件...即使使用“在tuto中使用预先录制的文件”这一部分......

答案 1 :(得分:1)

您是否将设置设为advisorConfigurationSettings的{​​{1}}?

SKRoutingService

您还必须设置音频文件的路径,如下所示:

[SKRoutingService sharedInstance].advisorConfigurationSettings = advisorSettings;

NSBundle* advisorResourcesBundle = [NSBundle bundleWithPath:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"SKAdvisorResources.bundle"]]; NSString* soundFilesFolder = [advisorResourcesBundle pathForResource:@"Languages" ofType:@""]; NSString* audioFilesFolderPath = [NSString stringWithFormat:@"%@/%@/sound_files",soundFilesFolder,userLanguageCode]; [AudioService sharedInstance].audioFilesFolderPath = audioFilesFolderPath; 在您的案例中为userLanguageCode

答案 2 :(得分:1)

代码中有一个错误,应该播放音频建议" (在AudioService.m中) - 未正确构建.mp3文件的名称。

我通过进行以下更改来解决此问题:

func playAudioFile(audioFileName: String) { 
    var soundFilePath: String = audioFilesFolderPath + "/" + audioFileName 
    soundFilePath = soundFilePath + ".mp3" 

    if !NSFileManager.defaultManager().fileExistsAtPath(soundFilePath) 
    { 
        return 
    } 
    else 
    { 
        audioPlayer = try? AVAudioPlayer(contentsOfURL: NSURL(fileURLWithPath: soundFilePath), fileTypeHint: nil) 
        audioPlayer.delegate = self 
        audioPlayer.play() 
    } 

} 

这只影响了swift演示,并将在下次更新中修复