语音合成(Synthesizer)
#类IFlySpeechSynthesizer
Declared in: IFlySpeechSynthesizer.h
#简介
#方法
#delegate
@property (nonatomic, assign) id<IFlySpeechSynthesizerDelegate> delegate
IFlySpeechSynthesizer.h
#sharedInstance
+ (instancetype)sharedInstance
合成对象
IFlySpeechSynthesizer.h
#destroy
+ (BOOL)destroy
成功返回YES,失败返回NO.
IFlySpeechSynthesizer.h
#setParameter:forKey:
- (BOOL)setParameter:(NSString *)value forKey:(NSString *)key
value | 参数取值 |
---|---|
key | 合成参数 |
设置成功返回YES,失败返回NO
参数 | 描述 |
---|---|
speed | 合成语速,取值范围 0~100 |
volume | 合成的音量,取值范围 0~100 |
voice_name | 默认为”xiaoyan”;可以设置的参数列表可参考个性化发音人列表 |
sample_rate | 采样率:目前支持的采样率设置有 16000 和 8000(高品质离线合成暂不支持)。 |
tts_audio_path | 音频文件名 设置此参数后,将会自动保存合成的音频文件。 路径为Documents/(指定值)。不设置或者设置为nil,则不保存音频。 |
params | 扩展参数: 对于一些特殊的参数可在此设置。 |
IFlySpeechSynthesizer.h
#parameterForKey:
- (NSString *)parameterForKey:(NSString *)key
key | 参数key |
---|---|
参数值
IFlySpeechSynthesizer.h
#startSpeaking:
- (void)startSpeaking:(NSString *)text
text | 合成的文本 |
---|---|
IFlySpeechSynthesizer.h
#synthesize:toUri:
调用此函数进行合成,如果发生错误会回调错误onCompleted
- (void)synthesize:(NSString *)text toUri:(NSString *)uri
text | 合成的文本 |
---|---|
uri | 合成后,保存再本地的音频路径 |
IFlySpeechSynthesizer.h
#pauseSpeaking
暂停播放之后,合成不会暂停,仍会继续,如果发生错误则会回调错误onCompleted
- (void)pauseSpeaking
IFlySpeechSynthesizer.h
#resumeSpeaking
- (void)resumeSpeaking
IFlySpeechSynthesizer.h
#stopSpeaking
- (void)stopSpeaking
IFlySpeechSynthesizer.h
#isSpeaking
@property (nonatomic, readonly) BOOL isSpeaking
#协议IFlySpeechSynthesizerDelegate
Conforms to | NSObject |
---|---|
Declared in | IFlySpeechSynthesizerDelegate.h |
- (void)onCompleted:(IFlySpeechError *)error
error | 错误码 |
---|---|
IFlySpeechSynthesizerDelegate.h
#– onSpeakBegin
- (void)onSpeakBegin
IFlySpeechSynthesizerDelegate.h
#– onBufferProgress:message:
- (void)onBufferProgress:(int)progress message:(NSString *)msg
progress | 缓冲进度,0-100 |
---|---|
msg | 附件信息,此版本为nil |
IFlySpeechSynthesizerDelegate.h
#– onSpeakProgress:beginPos:endPos:
- (void)onSpeakProgress:(int)progress beginPos:(int)beginPos endPos:(int)endPos
progress | 当前播放进度,0-100 |
---|---|
beginPos | 当前播放文本的起始位置(按照字节计算),对于汉字(2字节)需/2处理 |
endPos | 当前播放文本的结束位置(按照字节计算),对于汉字(2字节)需/2处理 |
IFlySpeechSynthesizerDelegate.h
#– onSpeakPaused
- (void)onSpeakPaused
IFlySpeechSynthesizerDelegate.h
#– onSpeakResumed
注意:此回调方法SDK内部不执行,播放恢复全部在onSpeakBegin中执行
- (void)onSpeakResumed
IFlySpeechSynthesizerDelegate.h
#– onSpeakCancel
注意:此回调方法SDK内部不执行
- (void)onSpeakCancel
IFlySpeechSynthesizerDelegate.h
#– onEvent:arg0:arg1:data:
根据事件类型返回额外的数据
- (void)onEvent:(int)eventType arg0:(int)arg0 arg1:(int)arg1 data:(NSData *)eventData
eventType | 事件类型,具体参见IFlySpeechEventType枚举。目前只支持EVENT_TTS_BUFFER也就是实时返回合成音频。 |
---|---|
arg0 | arg0 |
arg1 | arg1 |
eventData | 事件数据 |
IFlySpeechSynthesizerDelegate.h
修改于 2023-12-21 04:12:33