Class TingWuRealtimeSession

java.lang.Object
com.alibaba.dashscope.resources.tingwu.TingWuRealtimeSession
All Implemented Interfaces:
AutoCloseable

public final class TingWuRealtimeSession extends Object implements AutoCloseable
Realtime TingWu session (ws duplex, task protocol; task_group aigc, task multimodal-generation, function generation). Pull model — no SDK threads; user discipline is one send thread + one receive thread, finally close().

Lazy: nothing connects until start(). events() streams raw frames live until the speech-end action (or task end); a payload-level task-failed action raises through the error catalog like the header-level one.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Idempotent.
    Iterable<com.fasterxml.jackson.databind.JsonNode>
    Raw event frames (header included), ending at the speech-end action (inclusive) or task-finished; header- and payload-level task-failed both raise.
     
     
    void
    sendAudioFrame(byte[] data)
    Send one raw audio frame (format/sampleRate as configured).
    void
     
    void
    Connect (unless a shared connection was supplied), send run-task, block until task-started.
    void
    Signal end of audio (finish-task with {appId, directive: "stop"}); results keep arriving as events until speech-end.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • start

      public void start()
      Connect (unless a shared connection was supplied), send run-task, block until task-started.
    • sendAudioFrame

      public void sendAudioFrame(byte[] data)
      Send one raw audio frame (format/sampleRate as configured).
    • sendAudioFrame

      public void sendAudioFrame(ByteBuffer data)
    • stop

      public void stop()
      Signal end of audio (finish-task with {appId, directive: "stop"}); results keep arriving as events until speech-end.
    • events

      public Iterable<com.fasterxml.jackson.databind.JsonNode> events()
      Raw event frames (header included), ending at the speech-end action (inclusive) or task-finished; header- and payload-level task-failed both raise.
    • getTaskId

      public String getTaskId()
    • getRequestId

      public String getRequestId()
    • close

      public void close()
      Idempotent. With a shared connection this detaches the task only — unless the task owns the binary uplink and closed before its terminal event, which tears the whole shared connection down (binary frames carry no task id, so the lane cannot be handed over safely). The session may be re-started afterwards; on a torn-down shared connection the re-start fails fast.
      Specified by:
      close in interface AutoCloseable