Logo
Short Text to Speech

IOS SDK

TTS IOS SDK

1. Integration Steps

  1. Manual Import: Drag the HYTTS.framework into your project. Then, in General -> Frameworks, Libraries, and Embedded Content, change the Embed setting of HYTTS.framework to Embed & Sign.

  2. Ensure that the following pods are included: SocketRocket0.6.0、 AFNetworking, SSZipArchive 2.4.3。

1.Add Privacy - Microphone Usage Description to your project's info.plist file to enable microphone access.

3. Call Steps/Example Code

3.1 Get Instance

  • Obtain an instance of TTS
    TTSParams *params = [[TTSParams alloc] init];
    params.langType = @"";
    [[TTSManger shareInstance] setSdkParams:params]
    [[TTSManger shareInstance] initWithWithAppid:@"" WithAppSecret:@"" WithinitBlock:^(NSError * _Nonnull Error) {
        
        if (Error == nil) {
            NSLog(@"Initialization successful");
        }
        
    }];
   

3.2 Authorization Activation

(1)Configure Authorization Parameters

NameTypeDescriptionDefault Value
onlinestringtrue for online, false for offlinetrue
    TTSParams *parames = [[TTSManger getTTSManger] getSdkParams];
    params.online = @"true";//Online or offline

3.3 Parameter Settings

ParameterTypeRequiredDescriptionDefault Value
textStringYesText to be synthesized, length limit: 1024 bytes (UTF-8 encoding)Required
lang_typeStringYesLanguage optionRequired
voiceStringNoVoiceIDJapanese: Yuko
English:Julie
Chinese:Xiaohui
formatStringNoAudio encode format, wav / pcm / mp3,
note: wav does not support streaming
pcm
sample_rateIntegerNoAudio sample rate, options are 8000, 16000, 2400024000
volumeIntegerNoVolume, parameter range [0.1, 3], usually retaining one decimal place is sufficient1.0
speech_rateFloatNoSpeech rate, parameter range [0.2, 3], usually retaining one decimal place is sufficient1.0
pitch_rateFloatNoPitch rate, parameter range [0.1, 3], usually retaining one decimal place is sufficient1.0
emotionStringNoEmotional styleNo
silence_durationIntegerNoSilence duration at the end of the sentence, in ms125
enable_timestampBooleanNoTimestamp related, when passed as true, it indicates enabling, and the original text’s timestamps can be returned. Note: multiple consecutive punctuation or spaces in the original text will still be processed, but this will not affect the continuity of the timestampsfalse

TTSParams *params = [[TTSParams alloc] init]; params.text = @"";
params.langType = @"";
params.format = @"pcm";
params.voice = @"xiaohui";
params.volume = 50;
params.speech_rate = 1;
params.pitch_rate = 0;
params.sample_rate = 16000;
[[TTSManger shareInstance] setSdkParams:params];

3.4 Start/Stop Synthesis

TTSParams *parames = [[TTSManger getTTSManger] getSdkParams];
parames.text = @"";
[[TTSManger getTTSManger] onStart];//Start synthesis
[[TTSManger getTTSManger] onStop]; //Stop synthesis

4 SDK Download

iOS SDK

iOS Demo