public final class SpeechSynthesizer extends Object
| 构造器和说明 |
|---|
SpeechSynthesizer()
CosyVoice Speech Synthesis SDK
|
SpeechSynthesizer(SpeechSynthesisParam param,
ResultCallback<SpeechSynthesisResult> callback)
CosyVoice Speech Synthesis SDK
|
SpeechSynthesizer(SpeechSynthesisParam param,
ResultCallback<SpeechSynthesisResult> callback,
String baseUrl)
CosyVoice Speech Synthesis SDK
|
SpeechSynthesizer(SpeechSynthesisParam param,
ResultCallback<SpeechSynthesisResult> callback,
String baseUrl,
ConnectionOptions connectionOptions)
CosyVoice Speech Synthesis SDK
|
SpeechSynthesizer(String baseUrl,
ConnectionOptions connectionOptions)
CosyVoice Speech Synthesis SDK
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
asyncStreamingComplete()
Asynchronously stop the streaming input speech synthesis task, returns immediately.
|
ByteBuffer |
call(String text)
Speech synthesis If a callback is set, the audio will be returned in real-time through the
on_event interface Otherwise, this function blocks until all audio is received and then returns
the complete audio data.
|
ByteBuffer |
call(String text,
long timeoutMillis)
Speech synthesis If a callback is set, the audio will be returned in real-time through the
on_event interface Otherwise, this function blocks until all audio is received and then returns
the complete audio data.
|
io.reactivex.Flowable<SpeechSynthesisResult> |
callAsFlowable(String text)
Stream output speech synthesis using Flowable features (non-streaming input)
|
long |
getFirstPackageDelay()
First Package Delay is the time between start sending text and receive first audio package
|
String |
getLastRequestId() |
void |
streamingCall(String text)
Streaming input mode: You can call the stream_call function multiple times to send text.
|
io.reactivex.Flowable<SpeechSynthesisResult> |
streamingCallAsFlowable(io.reactivex.Flowable<String> textStream)
Stream input and output speech synthesis using Flowable features
|
void |
streamingCancel()
Immediately terminate the streaming input speech synthesis task and discard any remaining audio
that is not yet delivered.
|
void |
streamingComplete()
Synchronously stop the streaming input speech synthesis task.
|
void |
streamingComplete(long completeTimeoutMillis)
Synchronously stop the streaming input speech synthesis task.
|
void |
updateParamAndCallback(SpeechSynthesisParam param,
ResultCallback<SpeechSynthesisResult> callback) |
public SpeechSynthesizer(SpeechSynthesisParam param, ResultCallback<SpeechSynthesisResult> callback, String baseUrl, ConnectionOptions connectionOptions)
param - Configuration for speech synthesis, including voice type, volume, etc.callback - In non-streaming output scenarios, this can be set to nullbaseUrl - Base URLconnectionOptions - Connection optionspublic SpeechSynthesizer(String baseUrl, ConnectionOptions connectionOptions)
baseUrl - Base URLconnectionOptions - Connection optionspublic SpeechSynthesizer()
public SpeechSynthesizer(SpeechSynthesisParam param, ResultCallback<SpeechSynthesisResult> callback, String baseUrl)
param - Configuration for speech synthesis, including voice type, volume, etc.callback - In non-streaming output scenarios, this can be set to nullbaseUrl - Base URLpublic SpeechSynthesizer(SpeechSynthesisParam param, ResultCallback<SpeechSynthesisResult> callback)
param - Configuration for speech synthesis, including voice type, volume, etc.callback - In non-streaming output scenarios, this can be set to nullpublic void updateParamAndCallback(SpeechSynthesisParam param, ResultCallback<SpeechSynthesisResult> callback)
public String getLastRequestId()
public io.reactivex.Flowable<SpeechSynthesisResult> streamingCallAsFlowable(io.reactivex.Flowable<String> textStream) throws ApiException, NoApiKeyException
textStream - The text stream to be synthesizedApiExceptionNoApiKeyExceptionpublic io.reactivex.Flowable<SpeechSynthesisResult> callAsFlowable(String text) throws ApiException, NoApiKeyException
text - Text to be synthesizedApiExceptionNoApiKeyExceptionpublic void streamingComplete(long completeTimeoutMillis)
completeTimeoutMillis - The timeout period for await. If the timeout is set to a value
greater than zero, it will wait for the corresponding number of milliseconds; otherwise, it
will wait indefinitely. Throws TimeoutError exception if it times out.public void streamingComplete()
public void asyncStreamingComplete()
public void streamingCancel()
public void streamingCall(String text)
text - utf-8 encoded textpublic ByteBuffer call(String text, long timeoutMillis) throws RuntimeException
text - utf-8 encoded texttimeoutMillis - timeout for waiting audio data. If the timeout is set to a value greater
than zero, it will wait for the corresponding number of milliseconds; otherwise, it will
wait indefinitely.RuntimeExceptionpublic ByteBuffer call(String text)
text - utf-8 encoded textpublic long getFirstPackageDelay()
Copyright © 2025. All rights reserved.