Class SpeechSynthesizer
java.lang.Object
com.alibaba.dashscope.legacy_2x.audio.ttsv2.SpeechSynthesizer
Deprecated.
- Author:
- lengjiayi
-
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.CosyVoice Speech Synthesis SDKSpeechSynthesizer(SpeechSynthesisParam param, ResultCallback<SpeechSynthesisResult> callback) Deprecated.CosyVoice Speech Synthesis SDKSpeechSynthesizer(SpeechSynthesisParam param, ResultCallback<SpeechSynthesisResult> callback, String baseUrl) Deprecated.CosyVoice Speech Synthesis SDKSpeechSynthesizer(SpeechSynthesisParam param, ResultCallback<SpeechSynthesisResult> callback, String baseUrl, ConnectionOptions connectionOptions) Deprecated.CosyVoice Speech Synthesis SDKSpeechSynthesizer(String baseUrl, ConnectionOptions connectionOptions) Deprecated.CosyVoice Speech Synthesis SDK -
Method Summary
Modifier and TypeMethodDescriptionvoidDeprecated.Asynchronously stop the streaming input speech synthesis task, returns immediately.Deprecated.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.Deprecated.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) Deprecated.Stream output speech synthesis using Flowable features (non-streaming input)Deprecated.Deprecated.longDeprecated.longDeprecated.First Package Delay is the time between start sending text and receive first audio packageDeprecated.longDeprecated.voidsetFirstAudioTimeout(long firstAudioTimeout) Deprecated.voidsetStartedTimeout(long startedTimeout) Deprecated.voidstreamingCall(String text) Deprecated.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) Deprecated.Stream input and output speech synthesis using Flowable featuresvoidDeprecated.Immediately terminate the streaming input speech synthesis task and discard any remaining audio that is not yet delivered.voidDeprecated.Synchronously stop the streaming input speech synthesis task.voidstreamingComplete(long completeTimeoutMillis) Deprecated.Synchronously stop the streaming input speech synthesis task.voidDeprecated.voidstreamingFlush(com.google.gson.JsonObject params) Deprecated.voidupdateParamAndCallback(SpeechSynthesisParam param, ResultCallback<SpeechSynthesisResult> callback) Deprecated.
-
Constructor Details
-
SpeechSynthesizer
public SpeechSynthesizer(SpeechSynthesisParam param, ResultCallback<SpeechSynthesisResult> callback, String baseUrl, ConnectionOptions connectionOptions) Deprecated.CosyVoice Speech Synthesis SDK- Parameters:
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 options
-
SpeechSynthesizer
Deprecated.CosyVoice Speech Synthesis SDK- Parameters:
baseUrl- Base URLconnectionOptions- Connection options
-
SpeechSynthesizer
public SpeechSynthesizer()Deprecated.CosyVoice Speech Synthesis SDK -
SpeechSynthesizer
public SpeechSynthesizer(SpeechSynthesisParam param, ResultCallback<SpeechSynthesisResult> callback, String baseUrl) Deprecated.CosyVoice Speech Synthesis SDK- Parameters:
param- Configuration for speech synthesis, including voice type, volume, etc.callback- In non-streaming output scenarios, this can be set to nullbaseUrl- Base URL
-
SpeechSynthesizer
public SpeechSynthesizer(SpeechSynthesisParam param, ResultCallback<SpeechSynthesisResult> callback) Deprecated.CosyVoice Speech Synthesis SDK- Parameters:
param- Configuration for speech synthesis, including voice type, volume, etc.callback- In non-streaming output scenarios, this can be set to null
-
-
Method Details
-
updateParamAndCallback
public void updateParamAndCallback(SpeechSynthesisParam param, ResultCallback<SpeechSynthesisResult> callback) Deprecated. -
getLastRequestId
Deprecated. -
streamingCallAsFlowable
public io.reactivex.Flowable<SpeechSynthesisResult> streamingCallAsFlowable(io.reactivex.Flowable<String> textStream) throws ApiException, NoApiKeyException Deprecated.Stream input and output speech synthesis using Flowable features- Parameters:
textStream- The text stream to be synthesized- Returns:
- The output event stream, including real-time audio and timestamps
- Throws:
ApiExceptionNoApiKeyException
-
callAsFlowable
public io.reactivex.Flowable<SpeechSynthesisResult> callAsFlowable(String text) throws ApiException, NoApiKeyException Deprecated.Stream output speech synthesis using Flowable features (non-streaming input)- Parameters:
text- Text to be synthesized- Returns:
- The output event stream, including real-time audio and timestamps
- Throws:
ApiExceptionNoApiKeyException
-
streamingComplete
public void streamingComplete(long completeTimeoutMillis) Deprecated.Synchronously stop the streaming input speech synthesis task. Wait for all remaining synthesized audio before returning- Parameters:
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.
-
streamingComplete
public void streamingComplete()Deprecated.Synchronously stop the streaming input speech synthesis task. Wait for all remaining synthesized audio before returning. If it does not complete within 600 seconds, a timeout occurs and a TimeoutError exception is thrown. -
asyncStreamingComplete
public void asyncStreamingComplete()Deprecated.Asynchronously stop the streaming input speech synthesis task, returns immediately. You need to listen and handle the STREAM_INPUT_TTS_EVENT_SYNTHESIS_COMPLETE event in the on_event callback. Do not destroy the object and callback before this event. -
streamingCancel
public void streamingCancel()Deprecated.Immediately terminate the streaming input speech synthesis task and discard any remaining audio that is not yet delivered.The session always ends with
onComplete, even when the task fails after the cancel: the failure is suppressed as noise, but the terminal callback is still delivered so that the caller is never left waiting. -
streamingCall
Deprecated.Streaming input mode: You can call the stream_call function multiple times to send text. A session will be created on the first call. The session ends after calling streaming_complete.- Parameters:
text- utf-8 encoded text
-
streamingFlush
public void streamingFlush()Deprecated. -
streamingFlush
public void streamingFlush(com.google.gson.JsonObject params) Deprecated. -
call
Deprecated.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.- Parameters:
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.- Returns:
- If a callback is not set during initialization, the complete audio is returned as the function's return value. Otherwise, the return value is null.
- Throws:
ApiException- when no callback is set and the task fails, so that the caller gets the real cause instead of empty audio.RuntimeException
-
call
Deprecated.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.- Parameters:
text- utf-8 encoded text- Returns:
- If a callback is not set during initialization, the complete audio is returned as the function's return value. Otherwise, the return value is null.
- Throws:
ApiException- when no callback is set and the task fails, so that the caller gets the real cause instead of empty audio.
-
getFirstPackageDelay
public long getFirstPackageDelay()Deprecated.First Package Delay is the time between start sending text and receive first audio package -
getDuplexApi
Deprecated. -
getAudioData
Deprecated. -
getStartedTimeout
public long getStartedTimeout()Deprecated. -
setStartedTimeout
public void setStartedTimeout(long startedTimeout) Deprecated. -
getFirstAudioTimeout
public long getFirstAudioTimeout()Deprecated. -
setFirstAudioTimeout
public void setFirstAudioTimeout(long firstAudioTimeout) Deprecated.
-