Skip to content

Commit 21db159

Browse files
fix(Speech To Text): Can not get Audio Metrics with WebSocket
With WebSocket, AudioMetrics is returned as a other response
1 parent 0dfa433 commit 21db159

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/websocket/SpeechToTextWebSocketListener.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public final class SpeechToTextWebSocketListener extends WebSocketListener {
5454
private static final String ERROR = "error";
5555
private static final String RESULTS = "results";
5656
private static final String SPEAKER_LABELS = "speaker_labels";
57+
private static final String AUDIO_METRICS = "audio_metrics";
5758
private static final String CUSTOMIZATION_ID = "customization_id";
5859
private static final String LANGUAGE_CUSTOMIZATION_ID = "language_customization_id";
5960
private static final String ACOUSTIC_CUSTOMIZATION_ID = "acoustic_customization_id";
@@ -129,7 +130,7 @@ public void onMessage(WebSocket webSocket, String message) {
129130
// notify that the service timeouts because of inactivity
130131
callback.onInactivityTimeout(new RuntimeException(error));
131132
}
132-
} else if (json.has(RESULTS) || json.has(SPEAKER_LABELS)) {
133+
} else if (json.has(RESULTS) || json.has(SPEAKER_LABELS) || json.has(AUDIO_METRICS)) {
133134
callback.onTranscription(GSON.fromJson(message, SpeechRecognitionResults.class));
134135

135136
} else if (json.has(STATE)) {

0 commit comments

Comments
 (0)