Class TingWuRealtimeSession
java.lang.Object
com.alibaba.dashscope.resources.tingwu.TingWuRealtimeSession
- All Implemented Interfaces:
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 TypeMethodDescriptionvoidclose()Idempotent.Iterable<com.fasterxml.jackson.databind.JsonNode>events()Raw event frames (header included), ending at thespeech-endaction (inclusive) or task-finished; header- and payload-level task-failed both raise.voidsendAudioFrame(byte[] data) Send one raw audio frame (format/sampleRate as configured).voidsendAudioFrame(ByteBuffer data) voidstart()Connect (unless a shared connection was supplied), send run-task, block until task-started.voidstop()Signal end of audio (finish-task with{appId, directive: "stop"}); results keep arriving as events untilspeech-end.
-
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
-
stop
public void stop()Signal end of audio (finish-task with{appId, directive: "stop"}); results keep arriving as events untilspeech-end. -
events
Raw event frames (header included), ending at thespeech-endaction (inclusive) or task-finished; header- and payload-level task-failed both raise. -
getTaskId
-
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:
closein interfaceAutoCloseable
-