Class SpeechSynthesizer

java.lang.Object
com.alibaba.dashscope.legacy_2x.audio.ttsv2.SpeechSynthesizer

@Deprecated public final class SpeechSynthesizer extends Object
Deprecated.
Author:
lengjiayi
  • 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 null
      baseUrl - Base URL
      connectionOptions - Connection options
    • SpeechSynthesizer

      public SpeechSynthesizer(String baseUrl, ConnectionOptions connectionOptions)
      Deprecated.
      CosyVoice Speech Synthesis SDK
      Parameters:
      baseUrl - Base URL
      connectionOptions - 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 null
      baseUrl - 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

      public String 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:
      ApiException
      NoApiKeyException
    • 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:
      ApiException
      NoApiKeyException
    • 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

      public void streamingCall(String text)
      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

      public ByteBuffer call(String text, long timeoutMillis) throws RuntimeException
      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
      timeoutMillis - 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

      public ByteBuffer call(String text)
      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

      public ByteBuffer 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.