Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ public class OmniRealtimeConfig {
public JsonObject getConfig() {
Map<String, Object> 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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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<String, Object> tempMap = (Map<String, Object>) existingConfig;
tempMap.putAll(transcriptionConfig);
config.put(OmniRealtimeConstants.INPUT_AUDIO_TRANSCRIPTION, tempMap);
} else {
config.put(OmniRealtimeConstants.INPUT_AUDIO_TRANSCRIPTION, transcriptionConfig);
}
Comment thread
songguocola marked this conversation as resolved.
}
if (parameters != null) {
for (Map.Entry<String, Object> entry : parameters.entrySet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Comment thread
songguocola marked this conversation as resolved.
return;
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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()) {
Expand All @@ -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);
Expand Down
Loading