From 54d509b818938bb4a8d2a6717c189ded8d712caf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=81=A5=E4=BB=99?= Date: Thu, 23 Apr 2026 21:08:00 +0800 Subject: [PATCH 1/3] fix(websocket): fix close code error used --- .../dashscope/protocol/okhttp/OkHttpWebSocketClient.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/alibaba/dashscope/protocol/okhttp/OkHttpWebSocketClient.java b/src/main/java/com/alibaba/dashscope/protocol/okhttp/OkHttpWebSocketClient.java index 51a0310..157990b 100644 --- a/src/main/java/com/alibaba/dashscope/protocol/okhttp/OkHttpWebSocketClient.java +++ b/src/main/java/com/alibaba/dashscope/protocol/okhttp/OkHttpWebSocketClient.java @@ -207,7 +207,7 @@ public void onFailure(WebSocket webSocket, Throwable t, Response response) { if (isClosed.get()) { log.debug("called close before but not working, close again in onFailure."); - close(1013, "call closed before"); + close(1001, "call closed before"); return; } @@ -240,7 +240,7 @@ public void onFailure(WebSocket webSocket, Throwable t, Response response) { public void onMessage(WebSocket webSocket, String text) { if (isClosed.get()) { log.debug("called close before but not working, close again in onMessage."); - close(1013, "call closed before"); + close(1001, "call closed before"); return; } log.debug(text); @@ -339,7 +339,7 @@ public void onMessage(WebSocket webSocket, ByteString bytes) { // Invoked when a binary (type 0x2) message has been received. if (isClosed.get()) { log.debug("called close before but not working, close again in onMessage."); - close(1013, "call closed before"); + close(1001, "call closed before"); return; } if (!isFirstMessage.get()) { @@ -363,7 +363,7 @@ public void onOpen(WebSocket webSocket, Response response) { // messages.. if (isClosed.get()) { log.debug("called close before but not working, close again in onOpen."); - close(1013, "call closed before"); + close(1001, "call closed before"); return; } isOpen.set(true); From a0eba15f676792353fe62cbbb539870b28f9ee85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=81=A5=E4=BB=99?= Date: Mon, 27 Apr 2026 11:13:41 +0800 Subject: [PATCH 2/3] feat(model/cosyvoice): add parameters support in body build --- .../dashscope/audio/http_tts/HttpSpeechSynthesisParam.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/alibaba/dashscope/audio/http_tts/HttpSpeechSynthesisParam.java b/src/main/java/com/alibaba/dashscope/audio/http_tts/HttpSpeechSynthesisParam.java index 0c9af31..89e2c4e 100644 --- a/src/main/java/com/alibaba/dashscope/audio/http_tts/HttpSpeechSynthesisParam.java +++ b/src/main/java/com/alibaba/dashscope/audio/http_tts/HttpSpeechSynthesisParam.java @@ -4,6 +4,7 @@ import com.alibaba.dashscope.base.HalfDuplexServiceParam; import com.alibaba.dashscope.exception.InputRequiredException; +import com.alibaba.dashscope.utils.JsonUtils; import com.google.gson.JsonObject; import java.nio.ByteBuffer; import lombok.*; @@ -80,6 +81,9 @@ public JsonObject getHttpBody() { if (pitch != null) { input.addProperty("pitch", pitch); } + if (parameters != null && !parameters.isEmpty()) { + JsonUtils.merge(input, JsonUtils.parametersToJsonObject(parameters)); + } body.add("input", input); From 235b60fdb9ccf896e4c06c92bdacb64ca78880ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=81=A5=E4=BB=99?= Date: Mon, 27 Apr 2026 11:28:58 +0800 Subject: [PATCH 3/3] feat(model/live-translate): fix params build --- .../dashscope/audio/omni/OmniRealtimeConfig.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/alibaba/dashscope/audio/omni/OmniRealtimeConfig.java b/src/main/java/com/alibaba/dashscope/audio/omni/OmniRealtimeConfig.java index be127da..330f130 100644 --- a/src/main/java/com/alibaba/dashscope/audio/omni/OmniRealtimeConfig.java +++ b/src/main/java/com/alibaba/dashscope/audio/omni/OmniRealtimeConfig.java @@ -58,7 +58,9 @@ public class OmniRealtimeConfig { public JsonObject getConfig() { Map config = new HashMap<>(); config.put(OmniRealtimeConstants.MODALITIES, modalities); - config.put(OmniRealtimeConstants.VOICE, voice); + if (voice != null) { + config.put(OmniRealtimeConstants.VOICE, voice); + } config.put(OmniRealtimeConstants.INPUT_AUDIO_FORMAT, inputAudioFormat); config.put(OmniRealtimeConstants.OUTPUT_AUDIO_FORMAT, outputAudioFormat); if (enableInputAudioTranscription) { @@ -95,8 +97,6 @@ public JsonObject getConfig() { OmniRealtimeConstants.TRANSLATION_CORPUS, this.translationConfig.getCorpus()); } config.put(OmniRealtimeConstants.TRANSLATION, translationConfig); - } else { - config.put(OmniRealtimeConstants.TRANSLATION, null); } // Add transcription configuration for qwen-asr-realtime if (transcriptionConfig != null) { @@ -119,7 +119,15 @@ public JsonObject getConfig() { OmniRealtimeConstants.INPUT_AUDIO_TRANSCRIPTION_CORPUS, this.transcriptionConfig.getCorpus()); } - config.put(OmniRealtimeConstants.INPUT_AUDIO_TRANSCRIPTION, transcriptionConfig); + Object existingConfig = config.get(OmniRealtimeConstants.INPUT_AUDIO_TRANSCRIPTION); + if (existingConfig instanceof Map) { + @SuppressWarnings("unchecked") + Map tempMap = (Map) existingConfig; + tempMap.putAll(transcriptionConfig); + config.put(OmniRealtimeConstants.INPUT_AUDIO_TRANSCRIPTION, tempMap); + } else { + config.put(OmniRealtimeConstants.INPUT_AUDIO_TRANSCRIPTION, transcriptionConfig); + } } if (parameters != null) { for (Map.Entry entry : parameters.entrySet()) {