Skip to content

Commit 6696356

Browse files
feat(stt): readd interimResults and lowLatency wss params
1 parent e73ef5a commit 6696356

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RecognizeWithWebsocketsOptions.java

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,9 @@ public interface Model {
201201
protected Boolean splitTranscriptAtPhraseEnd;
202202
protected Float speechDetectorSensitivity;
203203
protected Float backgroundAudioSuppression;
204+
protected Boolean lowLatency;
204205
protected Float characterInsertionBias;
206+
private Boolean interimResults;
205207
private Boolean processingMetrics;
206208
private Float processingMetricsInterval;
207209

@@ -232,7 +234,9 @@ public static class Builder {
232234
private Boolean splitTranscriptAtPhraseEnd;
233235
private Float speechDetectorSensitivity;
234236
private Float backgroundAudioSuppression;
237+
private Boolean lowLatency;
235238
private Float characterInsertionBias;
239+
private Boolean interimResults;
236240
private Boolean processingMetrics;
237241
private Float processingMetricsInterval;
238242

@@ -262,7 +266,9 @@ private Builder(RecognizeWithWebsocketsOptions recognizeWithWebsocketsOptions) {
262266
this.splitTranscriptAtPhraseEnd = recognizeWithWebsocketsOptions.splitTranscriptAtPhraseEnd;
263267
this.speechDetectorSensitivity = recognizeWithWebsocketsOptions.speechDetectorSensitivity;
264268
this.backgroundAudioSuppression = recognizeWithWebsocketsOptions.backgroundAudioSuppression;
269+
this.lowLatency = recognizeWithWebsocketsOptions.lowLatency;
265270
this.characterInsertionBias = recognizeWithWebsocketsOptions.characterInsertionBias;
271+
this.interimResults = recognizeWithWebsocketsOptions.interimResults;
266272
this.processingMetrics = recognizeWithWebsocketsOptions.processingMetrics;
267273
this.processingMetricsInterval = recognizeWithWebsocketsOptions.processingMetricsInterval;
268274
}
@@ -578,6 +584,17 @@ public Builder backgroundAudioSuppression(Float backgroundAudioSuppression) {
578584
return this;
579585
}
580586

587+
/**
588+
* Set the lowLatency.
589+
*
590+
* @param lowLatency the lowLatency
591+
* @return the RecognizeOptions builder
592+
*/
593+
public Builder lowLatency(Boolean lowLatency) {
594+
this.lowLatency = lowLatency;
595+
return this;
596+
}
597+
581598
/**
582599
* Set the characterInsertionBias.
583600
*
@@ -589,6 +606,19 @@ public Builder characterInsertionBias(Float characterInsertionBias) {
589606
return this;
590607
}
591608

609+
/**
610+
* Set the interimResults.
611+
*
612+
* <p>NOTE: This parameter only works for the `recognizeUsingWebSocket` method.
613+
*
614+
* @param interimResults the interimResults
615+
* @return the interimResults
616+
*/
617+
public Builder interimResults(Boolean interimResults) {
618+
this.interimResults = interimResults;
619+
return this;
620+
}
621+
592622
/**
593623
* Set the audio.
594624
*
@@ -655,7 +685,9 @@ protected RecognizeWithWebsocketsOptions(Builder builder) {
655685
splitTranscriptAtPhraseEnd = builder.splitTranscriptAtPhraseEnd;
656686
speechDetectorSensitivity = builder.speechDetectorSensitivity;
657687
backgroundAudioSuppression = builder.backgroundAudioSuppression;
688+
lowLatency = builder.lowLatency;
658689
characterInsertionBias = builder.characterInsertionBias;
690+
interimResults = builder.interimResults;
659691
processingMetrics = builder.processingMetrics;
660692
processingMetricsInterval = builder.processingMetricsInterval;
661693
}
@@ -1091,6 +1123,28 @@ public Float backgroundAudioSuppression() {
10911123
return backgroundAudioSuppression;
10921124
}
10931125

1126+
/**
1127+
* Gets the lowLatency.
1128+
*
1129+
* <p>If `true` for next-generation `Multimedia` and `Telephony` models that support low latency,
1130+
* directs the service to produce results even more quickly than it usually does. Next-generation
1131+
* models produce transcription results faster than previous-generation models. The `low_latency`
1132+
* parameter causes the models to produce results even more quickly, though the results might be
1133+
* less accurate when the parameter is used.
1134+
*
1135+
* <p>The parameter is not available for previous-generation `Broadband` and `Narrowband` models.
1136+
* It is available for most next-generation models. * For a list of next-generation models that
1137+
* support low latency, see [Supported next-generation language
1138+
* models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-ng#models-ng-supported).
1139+
* * For more information about the `low_latency` parameter, see [Low
1140+
* latency](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-interim#low-latency).
1141+
*
1142+
* @return the lowLatency
1143+
*/
1144+
public Boolean lowLatency() {
1145+
return lowLatency;
1146+
}
1147+
10941148
/**
10951149
* Gets the characterInsertionBias.
10961150
*
@@ -1122,6 +1176,21 @@ public Float characterInsertionBias() {
11221176
return characterInsertionBias;
11231177
}
11241178

1179+
/**
1180+
* Gets the interimResults.
1181+
*
1182+
* <p>If `true`, the service returns interim results as a stream of `SpeechRecognitionResults`
1183+
* objects. By default, the service returns a single `SpeechRecognitionResults` object with final
1184+
* results only.
1185+
*
1186+
* <p>NOTE: This parameter only works for the `recognizeUsingWebSocket` method.
1187+
*
1188+
* @return the interimResults
1189+
*/
1190+
public Boolean interimResults() {
1191+
return interimResults;
1192+
}
1193+
11251194
/**
11261195
* Gets the processingMetrics.
11271196
*

speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/SpeechToTextIT.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ public void testRecognizeWebSocket() throws FileNotFoundException, InterruptedEx
347347
.wordAlternativesThreshold(0.5f)
348348
.model(EN_BROADBAND16K)
349349
.contentType(HttpMediaType.AUDIO_WAV)
350+
.interimResults(true)
350351
.processingMetrics(true)
351352
.processingMetricsInterval(0.2f)
352353
.audioMetrics(true)

0 commit comments

Comments
 (0)