Get offline TTS license from server failed with error 2
独孤伊人888888 发布于2016-10 浏览:2588 回复:1
0
收藏

我使用的服务是:离在线合成语音

调用的接口是:

参数设置情况:

开发平台和机型:Xcode8.1

SDK版本号:BDSSpeechSynthesizer_v_2.2.2_20160627A_COE

代码或日志截图(上传截图能帮助您更快解决问题):

//显示语音日志

    [BDSSpeechSynthesizer setLogLevel:BDS_PUBLIC_LOG_VERBOSE];

    [[BDSSpeechSynthesizer sharedInstance] setSynthesizerDelegate: self];

    /// 设置线程,默认使用主线程

    [[BDSSpeechSynthesizer sharedInstance] setSDKCallbackQueue:dispatch_queue_create("baiduVoiceQueue", DISPATCH_QUEUE_SERIAL)];

    

    

    // 设置委托对象

    [[BDSSpeechSynthesizer sharedInstance] setSynthesizerDelegate:self];

    // 设置apiKey和secretKey

    [[BDSSpeechSynthesizer sharedInstance] setApiKey:@"NtS5mUMVkLy1aVzFFTwgAGiP" withSecretKey:@"f643c0d285c8c83449d16b7ea625099a"];

    

    // 合成参数设置

    ///女声

    [[BDSSpeechSynthesizer sharedInstance] setSynthParam:

     [NSNumber numberWithInt:BDS_SYNTHESIZER_SPEAKER_FEMALE]

                                                  forKey:BDS_SYNTHESIZER_PARAM_SPEAKER];

    ///音量 0 ~9

    [[BDSSpeechSynthesizer sharedInstance] setSynthParam:[NSNumber numberWithInt:9] forKey:BDS_SYNTHESIZER_PARAM_VOLUME];

    

    ///语速 0 ~9

    [[BDSSpeechSynthesizer sharedInstance] setSynthParam:[NSNumber numberWithInt:6] forKey:BDS_SYNTHESIZER_PARAM_SPEED];

    

    ///语调 0 ~9

    [[BDSSpeechSynthesizer sharedInstance] setSynthParam: [NSNumber numberWithInt:5] forKey:BDS_SYNTHESIZER_PARAM_PITCH];

    ///mp3音质  压缩的16K

    [[BDSSpeechSynthesizer sharedInstance] setSynthParam:

     [NSNumber numberWithInt: BDS_SYNTHESIZER_AUDIO_ENCODE_MP3_16K]

                                                  forKey:BDS_SYNTHESIZER_PARAM_AUDIO_ENCODING ];

    

    [[BDSSpeechSynthesizer sharedInstance] setSynthParam:[NSNumber numberWithFloat:10.0] forKey:BDS_SYNTHESIZER_PARAM_ONLINE_REQUEST_TIMEOUT];

    

    /// 离线相关设置

    

    NSString* offlineEngineSpeechData = [[NSBundle mainBundle] pathForResource:@"Chinese_Speech_Female" ofType:@"dat"];

    NSString* offlineEngineTextData = [[NSBundle mainBundle] pathForResource:@"Chinese_Text" ofType:@"dat"];

    NSString* offlineEngineEnglishSpeechData = [[NSBundle mainBundle] pathForResource:@"English_Speech_Female" ofType:@"dat"];

    NSString* offlineEngineEnglishTextData = [[NSBundle mainBundle] pathForResource:@"English_Text" ofType:@"dat"];

    NSString* offlineEngineLicenseFile = [[NSBundle mainBundle] pathForResource:@"offline_engine_tmp_license" ofType:@"dat"];

    

    

    ///无法实现离线语音请检查以下部分

    NSError* err = [[BDSSpeechSynthesizer sharedInstance] loadOfflineEngine:offlineEngineTextData speechDataPath:offlineEngineSpeechData licenseFilePath:offlineEngineLicenseFile withAppCode:@"8771483"];

    

    if(err != nil)

    {

        // 处理出错状况

        NSLog(@"_________________%@",[err localizedDescription]);

    }

    err = [[BDSSpeechSynthesizer sharedInstance] loadEnglishDataForOfflineEngine:offlineEngineEnglishTextData speechData:offlineEngineEnglishSpeechData];

    if(err != nil)

    {

        // 处理出错状况

        NSLog(@"_________________%@",err);

    }

    // 开始合成并播放

    NSError* speakError = nil;

    if([[BDSSpeechSynthesizer sharedInstance] speakSentence:@"您好" withError:&speakError] == -1){

        // 错误

        NSLog(@"错误: %ld, %@", (long)speakError.code, speakError.localizedDescription);

    }

复现步骤、现象及其他描述:

Get offline TTS license from server failed with error 2


收藏
点赞
0
个赞
共1条回复 最后由du4602回复于2022-04
#2fang4096回复于2016-11

请确认下是否申请了离线合成的功能,并把临时授权文件移除,看一下是否修复该问题。

0
TOP
切换版块