public class SpeechSynthesizer extends SpeechReqProtocol
SpeechReqProtocol.StateaccessToken, conn, context, currentTaskId, header, payload, state| 构造器和说明 |
|---|
SpeechSynthesizer(NlsClient client,
SpeechSynthesizerListener listener) |
SpeechSynthesizer(NlsClient client,
String token,
SpeechSynthesizerListener listener) |
| 限定符和类型 | 方法和说明 |
|---|---|
protected void |
afterConnection(SpeechSynthesizerListener listener) |
void |
close()
关闭连接
|
void |
setFormat(OutputFormatEnum format)
合成语音的编码格式,支持的格式:pcm,wav,mp3 默认是pcm
|
void |
setLongText(String text) |
void |
setMethod(int method)
语音合成方法 默认为0
0 统计参数合成
基于统计参数的语音合成,优点是能适应的韵律特征的范围较宽,合成器比特率低,资源占用小,性能高,音质适中
1 波形拼接合成
基于高质量音库提取学习合成,资源占用相对较高,音质较好,更加贴近真实发音,但没有参数合成稳定
|
void |
setPitchRate(int pitchRate)
语调,范围是-500~500,可选,默认是0
|
void |
setSampleRate(int sampleRate)
个别场景需要设置除'SampleRateEnum'之外的采样率,如32000,采用此方法进行设置
|
void |
setSampleRate(SampleRateEnum sampleRate)
合成语音的采样率,可选默认16000
|
void |
setSpeechRate(int speechRate)
语速,范围是-500~500,可选,默认是0
|
void |
setText(String text)
待合成文本
|
void |
setVoice(String voice)
发音人
|
void |
setVolume(int volume)
音量,范围是0~100,可选,默认50
|
void |
start()
开始语音合成
|
void |
waitForComplete()
等待语音合成结束
|
void |
waitForComplete(int seconds)
等待语音合成结束
|
addCustomedParam, getAccessToken, getAppKey, getConnection, getState, getTaskId, putContext, serialize, setAppKey, setTaskIdpublic SpeechSynthesizer(NlsClient client, SpeechSynthesizerListener listener) throws Exception
Exceptionpublic SpeechSynthesizer(NlsClient client, String token, SpeechSynthesizerListener listener) throws Exception
Exceptionprotected void afterConnection(SpeechSynthesizerListener listener)
public void setVoice(String voice)
voice - public void setText(String text)
text - public void setLongText(String text)
public void setFormat(OutputFormatEnum format)
format - public void setSampleRate(SampleRateEnum sampleRate)
sampleRate - public void setSampleRate(int sampleRate)
sampleRate - public void setVolume(int volume)
volume - public void setSpeechRate(int speechRate)
speechRate - public void setPitchRate(int pitchRate)
pitchRate - public void setMethod(int method)
method - public void start()
throws Exception
start 在类中 SpeechReqProtocolExceptionpublic void waitForComplete(int seconds)
throws Exception
seconds - 最多等待多久就按超时处理Exceptionpublic void close()
Copyright © 2019. All rights reserved.