diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DtmfCommandInfo.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DtmfCommandInfo.java new file mode 100644 index 0000000000..572d8c758b --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DtmfCommandInfo.java @@ -0,0 +1,60 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.watson.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Map; + +/** DtmfCommandInfo. */ +public class DtmfCommandInfo extends GenericModel { + + /** Specifies the type of DTMF command for the phone integration. */ + public interface Type { + /** collect. */ + String COLLECT = "collect"; + /** disable_barge_in. */ + String DISABLE_BARGE_IN = "disable_barge_in"; + /** enable_barge_in. */ + String ENABLE_BARGE_IN = "enable_barge_in"; + /** send. */ + String SEND = "send"; + } + + protected String type; + protected Map parameters; + + protected DtmfCommandInfo() {} + + /** + * Gets the type. + * + *

Specifies the type of DTMF command for the phone integration. + * + * @return the type + */ + public String getType() { + return type; + } + + /** + * Gets the parameters. + * + *

Parameters specified by the command type. + * + * @return the parameters + */ + public Map getParameters() { + return parameters; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGeneric.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGeneric.java index 1bd2e700f4..31ab92e73f 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGeneric.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGeneric.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2025. + * (C) Copyright IBM Corp. 2019, 2026. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -31,7 +31,9 @@ * RuntimeResponseGenericRuntimeResponseTypeSearch - * RuntimeResponseGenericRuntimeResponseTypeUserDefined - * RuntimeResponseGenericRuntimeResponseTypeVideo - RuntimeResponseGenericRuntimeResponseTypeAudio - - * RuntimeResponseGenericRuntimeResponseTypeIframe - RuntimeResponseGenericRuntimeResponseTypeDate + * RuntimeResponseGenericRuntimeResponseTypeIframe - RuntimeResponseGenericRuntimeResponseTypeDate - + * RuntimeResponseGenericRuntimeResponseTypeDtmf - + * RuntimeResponseGenericRuntimeResponseTypeEndSession */ public class RuntimeResponseGeneric extends GenericModel { @SuppressWarnings("unused") @@ -60,6 +62,9 @@ public class RuntimeResponseGeneric extends GenericModel { discriminatorMapping.put( "user_defined", RuntimeResponseGenericRuntimeResponseTypeUserDefined.class); discriminatorMapping.put("video", RuntimeResponseGenericRuntimeResponseTypeVideo.class); + discriminatorMapping.put("dtmf", RuntimeResponseGenericRuntimeResponseTypeDtmf.class); + discriminatorMapping.put( + "end_session", RuntimeResponseGenericRuntimeResponseTypeEndSession.class); } /** The preferred type of control to display. */ public interface Preference { @@ -134,6 +139,9 @@ public interface Preference { @SerializedName("image_url") protected String imageUrl; + @SerializedName("command_info") + protected DtmfCommandInfo commandInfo; + protected RuntimeResponseGeneric() {} /** @@ -470,4 +478,13 @@ public Map channelOptions() { public String imageUrl() { return imageUrl; } + + /** + * Gets the commandInfo. + * + * @return the commandInfo + */ + public DtmfCommandInfo commandInfo() { + return commandInfo; + } } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeDtmf.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeDtmf.java new file mode 100644 index 0000000000..832398bd95 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeDtmf.java @@ -0,0 +1,20 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.watson.assistant.v2.model; + +/** RuntimeResponseGenericRuntimeResponseTypeDtmf. */ +public class RuntimeResponseGenericRuntimeResponseTypeDtmf extends RuntimeResponseGeneric { + + protected RuntimeResponseGenericRuntimeResponseTypeDtmf() {} +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeEndSession.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeEndSession.java new file mode 100644 index 0000000000..50774bb020 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeEndSession.java @@ -0,0 +1,20 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.watson.assistant.v2.model; + +/** RuntimeResponseGenericRuntimeResponseTypeEndSession. */ +public class RuntimeResponseGenericRuntimeResponseTypeEndSession extends RuntimeResponseGeneric { + + protected RuntimeResponseGenericRuntimeResponseTypeEndSession() {} +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CompleteItemTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CompleteItemTest.java index 8e240b641a..5708ace7d9 100644 --- a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CompleteItemTest.java +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CompleteItemTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2024, 2025. + * (C) Copyright IBM Corp. 2024, 2026. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -60,6 +60,7 @@ public void testCompleteItem() throws Throwable { assertNull(completeItemModel.userDefined()); assertNull(completeItemModel.channelOptions()); assertNull(completeItemModel.imageUrl()); + assertNull(completeItemModel.commandInfo()); assertNull(completeItemModel.getStreamingMetadata()); } } diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DtmfCommandInfoTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DtmfCommandInfoTest.java new file mode 100644 index 0000000000..a07f30242a --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DtmfCommandInfoTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DtmfCommandInfo model. */ +public class DtmfCommandInfoTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDtmfCommandInfo() throws Throwable { + DtmfCommandInfo dtmfCommandInfoModel = new DtmfCommandInfo(); + assertNull(dtmfCommandInfoModel.getType()); + assertNull(dtmfCommandInfoModel.getParameters()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeDtmfTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeDtmfTest.java new file mode 100644 index 0000000000..41dbff7793 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeDtmfTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypeDtmf model. */ +public class RuntimeResponseGenericRuntimeResponseTypeDtmfTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeDtmf() throws Throwable { + RuntimeResponseGenericRuntimeResponseTypeDtmf + runtimeResponseGenericRuntimeResponseTypeDtmfModel = + new RuntimeResponseGenericRuntimeResponseTypeDtmf(); + assertNull(runtimeResponseGenericRuntimeResponseTypeDtmfModel.responseType()); + assertNull(runtimeResponseGenericRuntimeResponseTypeDtmfModel.commandInfo()); + assertNull(runtimeResponseGenericRuntimeResponseTypeDtmfModel.channels()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeEndSessionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeEndSessionTest.java new file mode 100644 index 0000000000..e9e71df7ec --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeEndSessionTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypeEndSession model. */ +public class RuntimeResponseGenericRuntimeResponseTypeEndSessionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeEndSession() throws Throwable { + RuntimeResponseGenericRuntimeResponseTypeEndSession + runtimeResponseGenericRuntimeResponseTypeEndSessionModel = + new RuntimeResponseGenericRuntimeResponseTypeEndSession(); + assertNull(runtimeResponseGenericRuntimeResponseTypeEndSessionModel.responseType()); + assertNull(runtimeResponseGenericRuntimeResponseTypeEndSessionModel.channelOptions()); + } +} diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/SpeechToText.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/SpeechToText.java index e26990f3a5..9c8538ef78 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/SpeechToText.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/SpeechToText.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2025. + * (C) Copyright IBM Corp. 2016, 2026. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -51,6 +51,7 @@ import com.ibm.watson.speech_to_text.v1.model.DeleteLanguageModelOptions; import com.ibm.watson.speech_to_text.v1.model.DeleteUserDataOptions; import com.ibm.watson.speech_to_text.v1.model.DeleteWordOptions; +import com.ibm.watson.speech_to_text.v1.model.DetectLanguageOptions; import com.ibm.watson.speech_to_text.v1.model.GetAcousticModelOptions; import com.ibm.watson.speech_to_text.v1.model.GetAudioOptions; import com.ibm.watson.speech_to_text.v1.model.GetCorpusOptions; @@ -60,6 +61,7 @@ import com.ibm.watson.speech_to_text.v1.model.GetWordOptions; import com.ibm.watson.speech_to_text.v1.model.Grammar; import com.ibm.watson.speech_to_text.v1.model.Grammars; +import com.ibm.watson.speech_to_text.v1.model.LanguageDetectionResults; import com.ibm.watson.speech_to_text.v1.model.LanguageModel; import com.ibm.watson.speech_to_text.v1.model.LanguageModels; import com.ibm.watson.speech_to_text.v1.model.ListAcousticModelsOptions; @@ -447,6 +449,9 @@ public ServiceCall recognize(RecognizeOptions recogniz if (recognizeOptions.speechBeginEvent() != null) { builder.query("speech_begin_event", String.valueOf(recognizeOptions.speechBeginEvent())); } + if (recognizeOptions.enrichments() != null) { + builder.query("enrichments", String.valueOf(recognizeOptions.enrichments())); + } if (recognizeOptions.languageCustomizationId() != null) { builder.query( "language_customization_id", String.valueOf(recognizeOptions.languageCustomizationId())); @@ -776,6 +781,12 @@ public ServiceCall createJob(CreateJobOptions createJobOptions) if (createJobOptions.resultsTtl() != null) { builder.query("results_ttl", String.valueOf(createJobOptions.resultsTtl())); } + if (createJobOptions.speechBeginEvent() != null) { + builder.query("speech_begin_event", String.valueOf(createJobOptions.speechBeginEvent())); + } + if (createJobOptions.enrichments() != null) { + builder.query("enrichments", String.valueOf(createJobOptions.enrichments())); + } if (createJobOptions.languageCustomizationId() != null) { builder.query( "language_customization_id", String.valueOf(createJobOptions.languageCustomizationId())); @@ -2801,4 +2812,43 @@ public ServiceCall deleteUserData(DeleteUserDataOptions deleteUserDataOpti ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } + + /** + * Spoken language identification. + * + *

Detects the spoken language in audio streams. The endpoint is `/v1/detect_language` and user + * can optionally include `lid_confidence` parameter to set a custom confidence threshold for + * detection. The model continuously processes incoming audio and returns the identified language + * when it reaches a confidence level higher than the specified threshold (0.99 by default). See + * [Spoken language + * identification](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-speech-language-identification). + * + * @param detectLanguageOptions the {@link DetectLanguageOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link LanguageDetectionResults} + */ + public ServiceCall detectLanguage( + DetectLanguageOptions detectLanguageOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + detectLanguageOptions, "detectLanguageOptions cannot be null"); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/detect_language")); + Map sdkHeaders = + SdkCommon.getSdkHeaders("speech_to_text", "v1", "detectLanguage"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + if (detectLanguageOptions.contentType() != null) { + builder.header("Content-Type", detectLanguageOptions.contentType()); + } + builder.query("lid_confidence", String.valueOf(detectLanguageOptions.lidConfidence())); + builder.bodyContent( + detectLanguageOptions.contentType(), null, null, detectLanguageOptions.audio()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } } diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CreateJobOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CreateJobOptions.java index 08bec5f813..d517b837d4 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CreateJobOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CreateJobOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2025. + * (C) Copyright IBM Corp. 2018, 2026. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -247,6 +247,8 @@ public interface Events { protected String events; protected String userToken; protected Long resultsTtl; + protected Boolean speechBeginEvent; + protected String enrichments; protected String languageCustomizationId; protected String acousticCustomizationId; protected String baseModelVersion; @@ -284,6 +286,8 @@ public static class Builder { private String events; private String userToken; private Long resultsTtl; + private Boolean speechBeginEvent; + private String enrichments; private String languageCustomizationId; private String acousticCustomizationId; private String baseModelVersion; @@ -325,6 +329,8 @@ private Builder(CreateJobOptions createJobOptions) { this.events = createJobOptions.events; this.userToken = createJobOptions.userToken; this.resultsTtl = createJobOptions.resultsTtl; + this.speechBeginEvent = createJobOptions.speechBeginEvent; + this.enrichments = createJobOptions.enrichments; this.languageCustomizationId = createJobOptions.languageCustomizationId; this.acousticCustomizationId = createJobOptions.acousticCustomizationId; this.baseModelVersion = createJobOptions.baseModelVersion; @@ -467,6 +473,28 @@ public Builder resultsTtl(long resultsTtl) { return this; } + /** + * Set the speechBeginEvent. + * + * @param speechBeginEvent the speechBeginEvent + * @return the CreateJobOptions builder + */ + public Builder speechBeginEvent(Boolean speechBeginEvent) { + this.speechBeginEvent = speechBeginEvent; + return this; + } + + /** + * Set the enrichments. + * + * @param enrichments the enrichments + * @return the CreateJobOptions builder + */ + public Builder enrichments(String enrichments) { + this.enrichments = enrichments; + return this; + } + /** * Set the languageCustomizationId. * @@ -788,6 +816,8 @@ protected CreateJobOptions(Builder builder) { events = builder.events; userToken = builder.userToken; resultsTtl = builder.resultsTtl; + speechBeginEvent = builder.speechBeginEvent; + enrichments = builder.enrichments; languageCustomizationId = builder.languageCustomizationId; acousticCustomizationId = builder.acousticCustomizationId; baseModelVersion = builder.baseModelVersion; @@ -940,6 +970,41 @@ public Long resultsTtl() { return resultsTtl; } + /** + * Gets the speechBeginEvent. + * + *

If `true`, the service returns a response object `SpeechActivity` which contains the time + * when a speech activity is detected in the stream. This can be used both in standard and low + * latency mode. This feature enables client applications to know that some words/speech has been + * detected and the service is in the process of decoding. This can be used in lieu of interim + * results in standard mode. Use `sad_module: 2` to increase accuracy and performance in detecting + * speech boundaries within the audio stream. See [Using speech recognition + * parameters](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-service-features#features-parameters). + * + * @return the speechBeginEvent + */ + public Boolean speechBeginEvent() { + return speechBeginEvent; + } + + /** + * Gets the enrichments. + * + *

Speech transcript enrichment improves readability of raw ASR transcripts by adding + * punctuation (periods, commas, question marks, exclamation points) and intelligent + * capitalization (sentence beginnings, proper nouns, acronyms, brand names). To enable + * enrichment, add the `enrichments=punctuation` parameter to your recognition request. Supported + * languages include English (US, UK, Australia, India), French (France, Canada), German, Italian, + * Portuguese (Brazil, Portugal), Spanish (Spain, Latin America, Argentina, Chile, Colombia, + * Mexico, Peru), and Japanese. See [Speech transcript + * enrichment](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-speech-transcript-enrichment). + * + * @return the enrichments + */ + public String enrichments() { + return enrichments; + } + /** * Gets the languageCustomizationId. * diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DetectLanguageOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DetectLanguageOptions.java new file mode 100644 index 0000000000..95e8bf19ae --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DetectLanguageOptions.java @@ -0,0 +1,167 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.watson.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; + +/** The detectLanguage options. */ +public class DetectLanguageOptions extends GenericModel { + + protected Float lidConfidence; + protected InputStream audio; + protected String contentType; + + /** Builder. */ + public static class Builder { + private Float lidConfidence; + private InputStream audio; + private String contentType; + + /** + * Instantiates a new Builder from an existing DetectLanguageOptions instance. + * + * @param detectLanguageOptions the instance to initialize the Builder with + */ + private Builder(DetectLanguageOptions detectLanguageOptions) { + this.lidConfidence = detectLanguageOptions.lidConfidence; + this.audio = detectLanguageOptions.audio; + this.contentType = detectLanguageOptions.contentType; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param lidConfidence the lidConfidence + * @param audio the audio + */ + public Builder(Float lidConfidence, InputStream audio) { + this.lidConfidence = lidConfidence; + this.audio = audio; + } + + /** + * Builds a DetectLanguageOptions. + * + * @return the new DetectLanguageOptions instance + */ + public DetectLanguageOptions build() { + return new DetectLanguageOptions(this); + } + + /** + * Set the lidConfidence. + * + * @param lidConfidence the lidConfidence + * @return the DetectLanguageOptions builder + */ + public Builder lidConfidence(Float lidConfidence) { + this.lidConfidence = lidConfidence; + return this; + } + + /** + * Set the audio. + * + * @param audio the audio + * @return the DetectLanguageOptions builder + */ + public Builder audio(InputStream audio) { + this.audio = audio; + return this; + } + + /** + * Set the contentType. + * + * @param contentType the contentType + * @return the DetectLanguageOptions builder + */ + public Builder contentType(String contentType) { + this.contentType = contentType; + return this; + } + + /** + * Set the audio. + * + * @param audio the audio + * @return the DetectLanguageOptions builder + * @throws FileNotFoundException if the file could not be found + */ + public Builder audio(File audio) throws FileNotFoundException { + this.audio = new FileInputStream(audio); + return this; + } + } + + protected DetectLanguageOptions() {} + + protected DetectLanguageOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.lidConfidence, "lidConfidence cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.audio, "audio cannot be null"); + lidConfidence = builder.lidConfidence; + audio = builder.audio; + contentType = builder.contentType; + } + + /** + * New builder. + * + * @return a DetectLanguageOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the lidConfidence. + * + *

Set a custom confidence threshold for detection. + * + * @return the lidConfidence + */ + public Float lidConfidence() { + return lidConfidence; + } + + /** + * Gets the audio. + * + *

The audio to transcribe. + * + * @return the audio + */ + public InputStream audio() { + return audio; + } + + /** + * Gets the contentType. + * + *

The type of the input. + * + * @return the contentType + */ + public String contentType() { + return contentType; + } +} diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/EnrichedResults.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/EnrichedResults.java new file mode 100644 index 0000000000..b281622f26 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/EnrichedResults.java @@ -0,0 +1,51 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.watson.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * If enriched results are requested, transcription with inserted punctuation marks such as periods, + * commas, question marks, and exclamation points. + */ +public class EnrichedResults extends GenericModel { + + protected EnrichedResultsTranscript transcript; + protected String status; + + protected EnrichedResults() {} + + /** + * Gets the transcript. + * + *

If enriched results are requested, transcription with inserted punctuation marks such as + * periods, commas, question marks, and exclamation points. + * + * @return the transcript + */ + public EnrichedResultsTranscript getTranscript() { + return transcript; + } + + /** + * Gets the status. + * + *

The status of the enriched transcription. + * + * @return the status + */ + public String getStatus() { + return status; + } +} diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/EnrichedResultsTranscript.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/EnrichedResultsTranscript.java new file mode 100644 index 0000000000..6f67841a12 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/EnrichedResultsTranscript.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.watson.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * If enriched results are requested, transcription with inserted punctuation marks such as periods, + * commas, question marks, and exclamation points. + */ +public class EnrichedResultsTranscript extends GenericModel { + + protected String text; + protected EnrichedResultsTranscriptTimestamp timestamp; + + protected EnrichedResultsTranscript() {} + + /** + * Gets the text. + * + *

The transcript text. + * + * @return the text + */ + public String getText() { + return text; + } + + /** + * Gets the timestamp. + * + *

The speaking time from the beginning of the transcript to the end. + * + * @return the timestamp + */ + public EnrichedResultsTranscriptTimestamp getTimestamp() { + return timestamp; + } +} diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/EnrichedResultsTranscriptTimestamp.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/EnrichedResultsTranscriptTimestamp.java new file mode 100644 index 0000000000..0f918fe6d1 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/EnrichedResultsTranscriptTimestamp.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.watson.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The speaking time from the beginning of the transcript to the end. */ +public class EnrichedResultsTranscriptTimestamp extends GenericModel { + + protected Float from; + protected Float to; + + protected EnrichedResultsTranscriptTimestamp() {} + + /** + * Gets the from. + * + *

The start time of a word from the transcript. The value matches the start time of a word + * from the `timestamps` array. + * + * @return the from + */ + public Float getFrom() { + return from; + } + + /** + * Gets the to. + * + *

The end time of a word from the transcript. The value matches the end time of a word from + * the `timestamps` array. + * + * @return the to + */ + public Float getTo() { + return to; + } +} diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/LanguageDetectionResult.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/LanguageDetectionResult.java new file mode 100644 index 0000000000..3e9d3e4646 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/LanguageDetectionResult.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.watson.speech_to_text.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** Language detection results. */ +public class LanguageDetectionResult extends GenericModel { + + @SerializedName("language_info") + protected List languageInfo; + + protected LanguageDetectionResult() {} + + /** + * Gets the languageInfo. + * + *

An array of `LanguageInfo` objects. + * + * @return the languageInfo + */ + public List getLanguageInfo() { + return languageInfo; + } +} diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/LanguageDetectionResults.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/LanguageDetectionResults.java new file mode 100644 index 0000000000..e51c6757fe --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/LanguageDetectionResults.java @@ -0,0 +1,54 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.watson.speech_to_text.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** Language detection results. */ +public class LanguageDetectionResults extends GenericModel { + + protected List results; + + @SerializedName("result_index") + protected Long resultIndex; + + protected LanguageDetectionResults() {} + + /** + * Gets the results. + * + *

An array of `LanguageDetectionResult` objects. + * + * @return the results + */ + public List getResults() { + return results; + } + + /** + * Gets the resultIndex. + * + *

An index that indicates a change point in the `results` array. The service increments the + * index for additional results that it sends for new audio for the same request. All results with + * the same index are delivered at the same time. The same index can include multiple final + * results that are delivered with the same response. + * + * @return the resultIndex + */ + public Long getResultIndex() { + return resultIndex; + } +} diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/LanguageInfo.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/LanguageInfo.java new file mode 100644 index 0000000000..e771e534e9 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/LanguageInfo.java @@ -0,0 +1,60 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.watson.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Language detection info such as confidence and language detected. */ +public class LanguageInfo extends GenericModel { + + protected Float confidence; + protected String language; + protected Float timestamp; + + protected LanguageInfo() {} + + /** + * Gets the confidence. + * + *

A score that indicates the service's confidence in its identification of the language in the + * range of 0.0 to 1.0. + * + * @return the confidence + */ + public Float getConfidence() { + return confidence; + } + + /** + * Gets the language. + * + *

The language detected in standard abbreviated ISO 639 format. + * + * @return the language + */ + public String getLanguage() { + return language; + } + + /** + * Gets the timestamp. + * + *

The timestamp of the detected language. + * + * @return the timestamp + */ + public Float getTimestamp() { + return timestamp; + } +} diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RecognizeOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RecognizeOptions.java index 0b7ee243a2..dce3f99c6f 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RecognizeOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RecognizeOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2025. + * (C) Copyright IBM Corp. 2016, 2026. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -216,6 +216,7 @@ public interface Model { protected String contentType; protected String model; protected Boolean speechBeginEvent; + protected String enrichments; protected String languageCustomizationId; protected String acousticCustomizationId; protected String baseModelVersion; @@ -248,6 +249,7 @@ public static class Builder { private String contentType; private String model; private Boolean speechBeginEvent; + private String enrichments; private String languageCustomizationId; private String acousticCustomizationId; private String baseModelVersion; @@ -284,6 +286,7 @@ private Builder(RecognizeOptions recognizeOptions) { this.contentType = recognizeOptions.contentType; this.model = recognizeOptions.model; this.speechBeginEvent = recognizeOptions.speechBeginEvent; + this.enrichments = recognizeOptions.enrichments; this.languageCustomizationId = recognizeOptions.languageCustomizationId; this.acousticCustomizationId = recognizeOptions.acousticCustomizationId; this.baseModelVersion = recognizeOptions.baseModelVersion; @@ -391,6 +394,17 @@ public Builder speechBeginEvent(Boolean speechBeginEvent) { return this; } + /** + * Set the enrichments. + * + * @param enrichments the enrichments + * @return the RecognizeOptions builder + */ + public Builder enrichments(String enrichments) { + this.enrichments = enrichments; + return this; + } + /** * Set the languageCustomizationId. * @@ -687,6 +701,7 @@ protected RecognizeOptions(Builder builder) { contentType = builder.contentType; model = builder.model; speechBeginEvent = builder.speechBeginEvent; + enrichments = builder.enrichments; languageCustomizationId = builder.languageCustomizationId; acousticCustomizationId = builder.acousticCustomizationId; baseModelVersion = builder.baseModelVersion; @@ -784,6 +799,24 @@ public Boolean speechBeginEvent() { return speechBeginEvent; } + /** + * Gets the enrichments. + * + *

Speech transcript enrichment improves readability of raw ASR transcripts by adding + * punctuation (periods, commas, question marks, exclamation points) and intelligent + * capitalization (sentence beginnings, proper nouns, acronyms, brand names). To enable + * enrichment, add the `enrichments=punctuation` parameter to your recognition request. Supported + * languages include English (US, UK, Australia, India), French (France, Canada), German, Italian, + * Portuguese (Brazil, Portugal), Spanish (Spain, Latin America, Argentina, Chile, Colombia, + * Mexico, Peru), and Japanese. See [Speech transcript + * enrichment](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-speech-transcript-enrichment). + * + * @return the enrichments + */ + public String enrichments() { + return enrichments; + } + /** * Gets the languageCustomizationId. * diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResult.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResult.java index 79c7e0e3cd..0eb5b0563e 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResult.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2024. + * (C) Copyright IBM Corp. 2018, 2026. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -65,8 +65,7 @@ protected SpeechRecognitionResult() {} * results are interim. They can be updated with further interim results until final results are * eventually sent. * - *

**Note:** Because `final` is a reserved word in Java and Swift, the field is renamed - * `xFinal` in Java and is escaped with back quotes in Swift. + *

**Note:** Because `final` is a reserved word in Java, the field is renamed `xFinal` in Java. * * @return the xFinal */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResults.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResults.java index b9f3be382a..c8b6e89d39 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResults.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResults.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2024. + * (C) Copyright IBM Corp. 2018, 2026. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -36,6 +36,9 @@ public class SpeechRecognitionResults extends GenericModel { protected List warnings; + @SerializedName("enriched_results") + protected EnrichedResults enrichedResults; + protected SpeechRecognitionResults() {} /** @@ -135,4 +138,16 @@ public AudioMetrics getAudioMetrics() { public List getWarnings() { return warnings; } + + /** + * Gets the enrichedResults. + * + *

If enriched results are requested, transcription with inserted punctuation marks such as + * periods, commas, question marks, and exclamation points. + * + * @return the enrichedResults + */ + public EnrichedResults getEnrichedResults() { + return enrichedResults; + } } diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/SpeechToTextIT.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/SpeechToTextIT.java index 1d612850ce..5c622dcf99 100755 --- a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/SpeechToTextIT.java +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/SpeechToTextIT.java @@ -23,53 +23,7 @@ import com.ibm.cloud.sdk.core.service.exception.NotFoundException; import com.ibm.watson.common.RetryRunner; import com.ibm.watson.common.WatsonServiceTest; -import com.ibm.watson.speech_to_text.v1.model.AcousticModel; -import com.ibm.watson.speech_to_text.v1.model.AcousticModels; -import com.ibm.watson.speech_to_text.v1.model.AddAudioOptions; -import com.ibm.watson.speech_to_text.v1.model.AddCorpusOptions; -import com.ibm.watson.speech_to_text.v1.model.AddGrammarOptions; -import com.ibm.watson.speech_to_text.v1.model.AddWordOptions; -import com.ibm.watson.speech_to_text.v1.model.AudioListing; -import com.ibm.watson.speech_to_text.v1.model.AudioResources; -import com.ibm.watson.speech_to_text.v1.model.CheckJobOptions; -import com.ibm.watson.speech_to_text.v1.model.Corpora; -import com.ibm.watson.speech_to_text.v1.model.Corpus; -import com.ibm.watson.speech_to_text.v1.model.CreateAcousticModelOptions; -import com.ibm.watson.speech_to_text.v1.model.CreateJobOptions; -import com.ibm.watson.speech_to_text.v1.model.CreateLanguageModelOptions; -import com.ibm.watson.speech_to_text.v1.model.DeleteAcousticModelOptions; -import com.ibm.watson.speech_to_text.v1.model.DeleteAudioOptions; -import com.ibm.watson.speech_to_text.v1.model.DeleteGrammarOptions; -import com.ibm.watson.speech_to_text.v1.model.DeleteJobOptions; -import com.ibm.watson.speech_to_text.v1.model.DeleteLanguageModelOptions; -import com.ibm.watson.speech_to_text.v1.model.DeleteUserDataOptions; -import com.ibm.watson.speech_to_text.v1.model.GetAcousticModelOptions; -import com.ibm.watson.speech_to_text.v1.model.GetAudioOptions; -import com.ibm.watson.speech_to_text.v1.model.GetCorpusOptions; -import com.ibm.watson.speech_to_text.v1.model.GetGrammarOptions; -import com.ibm.watson.speech_to_text.v1.model.GetLanguageModelOptions; -import com.ibm.watson.speech_to_text.v1.model.GetModelOptions; -import com.ibm.watson.speech_to_text.v1.model.GetWordOptions; -import com.ibm.watson.speech_to_text.v1.model.Grammar; -import com.ibm.watson.speech_to_text.v1.model.Grammars; -import com.ibm.watson.speech_to_text.v1.model.KeywordResult; -import com.ibm.watson.speech_to_text.v1.model.LanguageModel; -import com.ibm.watson.speech_to_text.v1.model.LanguageModels; -import com.ibm.watson.speech_to_text.v1.model.ListAudioOptions; -import com.ibm.watson.speech_to_text.v1.model.ListCorporaOptions; -import com.ibm.watson.speech_to_text.v1.model.ListGrammarsOptions; -import com.ibm.watson.speech_to_text.v1.model.ListWordsOptions; -import com.ibm.watson.speech_to_text.v1.model.RecognitionJob; -import com.ibm.watson.speech_to_text.v1.model.RecognitionJobs; -import com.ibm.watson.speech_to_text.v1.model.RecognizeOptions; -import com.ibm.watson.speech_to_text.v1.model.RecognizeWithWebsocketsOptions; -import com.ibm.watson.speech_to_text.v1.model.SpeechModel; -import com.ibm.watson.speech_to_text.v1.model.SpeechModels; -import com.ibm.watson.speech_to_text.v1.model.SpeechRecognitionResult; -import com.ibm.watson.speech_to_text.v1.model.SpeechRecognitionResults; -import com.ibm.watson.speech_to_text.v1.model.Word; -import com.ibm.watson.speech_to_text.v1.model.WordAlternativeResults; -import com.ibm.watson.speech_to_text.v1.model.Words; +import com.ibm.watson.speech_to_text.v1.model.*; import com.ibm.watson.speech_to_text.v1.websocket.BaseRecognizeCallback; import java.io.File; import java.io.FileInputStream; @@ -204,6 +158,25 @@ public void testRecognizeFileString() throws FileNotFoundException { } } + /** + * Test recognize audio file. + * + * @throws FileNotFoundException the file not found exception + */ + @Test + public void testRecognizeEnrichments() throws FileNotFoundException { + File audio = new File(SAMPLE_WAV); + RecognizeOptions options = + new RecognizeOptions.Builder() + .audio(audio) + .contentType(HttpMediaType.AUDIO_WAV) + .enrichments("punctuation") + .build(); + SpeechRecognitionResults results = service.recognize(options).execute().getResult(); + + assertNotNull(results.getResults().get(0).getAlternatives().get(0).getTranscript()); + } + /** * Test recognize with silence. * @@ -1120,6 +1093,25 @@ public void testGrammarOperations() throws FileNotFoundException, InterruptedExc service.deleteGrammar(deleteGrammarOptions).execute(); } + /** + * Test detect language. + * + * @throws FileNotFoundException the file not found exception + */ + @Test + public void testdetectLanguage() throws FileNotFoundException { + File audio = new File(SAMPLE_WAV); + DetectLanguageOptions options = + new DetectLanguageOptions.Builder() + .audio(audio) + .contentType(HttpMediaType.AUDIO_WAV) + .lidConfidence(0.9f) + .build(); + LanguageDetectionResults results = service.detectLanguage(options).execute().getResult(); + + assertNotNull(results.getResults().get(0)); + } + private boolean isCustomizationReady(String customizationId) { GetLanguageModelOptions getLanguageModelOptions = new GetLanguageModelOptions.Builder().customizationId(customizationId).build(); diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/SpeechToTextTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/SpeechToTextTest.java index 2a32b0a815..70ba77e10d 100755 --- a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/SpeechToTextTest.java +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/SpeechToTextTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2025. + * (C) Copyright IBM Corp. 2026. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -45,6 +45,7 @@ import com.ibm.watson.speech_to_text.v1.model.DeleteLanguageModelOptions; import com.ibm.watson.speech_to_text.v1.model.DeleteUserDataOptions; import com.ibm.watson.speech_to_text.v1.model.DeleteWordOptions; +import com.ibm.watson.speech_to_text.v1.model.DetectLanguageOptions; import com.ibm.watson.speech_to_text.v1.model.GetAcousticModelOptions; import com.ibm.watson.speech_to_text.v1.model.GetAudioOptions; import com.ibm.watson.speech_to_text.v1.model.GetCorpusOptions; @@ -54,6 +55,7 @@ import com.ibm.watson.speech_to_text.v1.model.GetWordOptions; import com.ibm.watson.speech_to_text.v1.model.Grammar; import com.ibm.watson.speech_to_text.v1.model.Grammars; +import com.ibm.watson.speech_to_text.v1.model.LanguageDetectionResults; import com.ibm.watson.speech_to_text.v1.model.LanguageModel; import com.ibm.watson.speech_to_text.v1.model.LanguageModels; import com.ibm.watson.speech_to_text.v1.model.ListAcousticModelsOptions; @@ -213,7 +215,7 @@ public void testGetModelNoOptions() throws Throwable { public void testRecognizeWOptions() throws Throwable { // Register a mock response String mockResponseBody = - "{\"results\": [{\"final\": true, \"alternatives\": [{\"transcript\": \"transcript\", \"confidence\": 0, \"timestamps\": [[\"timestamps\"]], \"word_confidence\": [[\"wordConfidence\"]]}], \"keywords_result\": {\"mapKey\": [{\"normalized_text\": \"normalizedText\", \"start_time\": 9, \"end_time\": 7, \"confidence\": 0}]}, \"word_alternatives\": [{\"start_time\": 9, \"end_time\": 7, \"alternatives\": [{\"confidence\": 0, \"word\": \"word\"}]}], \"end_of_utterance\": \"end_of_data\"}], \"result_index\": 11, \"speaker_labels\": [{\"from\": 4, \"to\": 2, \"speaker\": 7, \"confidence\": 10, \"final\": true}], \"processing_metrics\": {\"processed_audio\": {\"received\": 8, \"seen_by_engine\": 12, \"transcription\": 13, \"speaker_labels\": 13}, \"wall_clock_since_first_byte_received\": 31, \"periodic\": true}, \"audio_metrics\": {\"sampling_interval\": 16, \"accumulated\": {\"final\": true, \"end_time\": 7, \"signal_to_noise_ratio\": 18, \"speech_ratio\": 11, \"high_frequency_loss\": 17, \"direct_current_offset\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"clipping_rate\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"speech_level\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"non_speech_level\": [{\"begin\": 5, \"end\": 3, \"count\": 5}]}}, \"warnings\": [\"warnings\"]}"; + "{\"results\": [{\"final\": true, \"alternatives\": [{\"transcript\": \"transcript\", \"confidence\": 0, \"timestamps\": [[\"timestamps\"]], \"word_confidence\": [[\"wordConfidence\"]]}], \"keywords_result\": {\"mapKey\": [{\"normalized_text\": \"normalizedText\", \"start_time\": 9, \"end_time\": 7, \"confidence\": 0}]}, \"word_alternatives\": [{\"start_time\": 9, \"end_time\": 7, \"alternatives\": [{\"confidence\": 0, \"word\": \"word\"}]}], \"end_of_utterance\": \"end_of_data\"}], \"result_index\": 11, \"speaker_labels\": [{\"from\": 4, \"to\": 2, \"speaker\": 7, \"confidence\": 10, \"final\": true}], \"processing_metrics\": {\"processed_audio\": {\"received\": 8, \"seen_by_engine\": 12, \"transcription\": 13, \"speaker_labels\": 13}, \"wall_clock_since_first_byte_received\": 31, \"periodic\": true}, \"audio_metrics\": {\"sampling_interval\": 16, \"accumulated\": {\"final\": true, \"end_time\": 7, \"signal_to_noise_ratio\": 18, \"speech_ratio\": 11, \"high_frequency_loss\": 17, \"direct_current_offset\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"clipping_rate\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"speech_level\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"non_speech_level\": [{\"begin\": 5, \"end\": 3, \"count\": 5}]}}, \"warnings\": [\"warnings\"], \"enriched_results\": {\"transcript\": {\"text\": \"text\", \"timestamp\": {\"from\": 4, \"to\": 2}}, \"status\": \"status\"}}"; String recognizePath = "/v1/recognize"; server.enqueue( new MockResponse() @@ -228,6 +230,7 @@ public void testRecognizeWOptions() throws Throwable { .contentType("application/octet-stream") .model("en-US_BroadbandModel") .speechBeginEvent(false) + .enrichments("testString") .languageCustomizationId("testString") .acousticCustomizationId("testString") .baseModelVersion("testString") @@ -274,6 +277,7 @@ public void testRecognizeWOptions() throws Throwable { assertNotNull(query); assertEquals(query.get("model"), "en-US_BroadbandModel"); assertEquals(Boolean.valueOf(query.get("speech_begin_event")), Boolean.valueOf(false)); + assertEquals(query.get("enrichments"), "testString"); assertEquals(query.get("language_customization_id"), "testString"); assertEquals(query.get("acoustic_customization_id"), "testString"); assertEquals(query.get("base_model_version"), "testString"); @@ -431,7 +435,7 @@ public void testUnregisterCallbackNoOptions() throws Throwable { public void testCreateJobWOptions() throws Throwable { // Register a mock response String mockResponseBody = - "{\"id\": \"id\", \"status\": \"waiting\", \"created\": \"created\", \"updated\": \"updated\", \"url\": \"url\", \"user_token\": \"userToken\", \"results\": [{\"results\": [{\"final\": true, \"alternatives\": [{\"transcript\": \"transcript\", \"confidence\": 0, \"timestamps\": [[\"timestamps\"]], \"word_confidence\": [[\"wordConfidence\"]]}], \"keywords_result\": {\"mapKey\": [{\"normalized_text\": \"normalizedText\", \"start_time\": 9, \"end_time\": 7, \"confidence\": 0}]}, \"word_alternatives\": [{\"start_time\": 9, \"end_time\": 7, \"alternatives\": [{\"confidence\": 0, \"word\": \"word\"}]}], \"end_of_utterance\": \"end_of_data\"}], \"result_index\": 11, \"speaker_labels\": [{\"from\": 4, \"to\": 2, \"speaker\": 7, \"confidence\": 10, \"final\": true}], \"processing_metrics\": {\"processed_audio\": {\"received\": 8, \"seen_by_engine\": 12, \"transcription\": 13, \"speaker_labels\": 13}, \"wall_clock_since_first_byte_received\": 31, \"periodic\": true}, \"audio_metrics\": {\"sampling_interval\": 16, \"accumulated\": {\"final\": true, \"end_time\": 7, \"signal_to_noise_ratio\": 18, \"speech_ratio\": 11, \"high_frequency_loss\": 17, \"direct_current_offset\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"clipping_rate\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"speech_level\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"non_speech_level\": [{\"begin\": 5, \"end\": 3, \"count\": 5}]}}, \"warnings\": [\"warnings\"]}], \"warnings\": [\"warnings\"]}"; + "{\"id\": \"id\", \"status\": \"waiting\", \"created\": \"created\", \"updated\": \"updated\", \"url\": \"url\", \"user_token\": \"userToken\", \"results\": [{\"results\": [{\"final\": true, \"alternatives\": [{\"transcript\": \"transcript\", \"confidence\": 0, \"timestamps\": [[\"timestamps\"]], \"word_confidence\": [[\"wordConfidence\"]]}], \"keywords_result\": {\"mapKey\": [{\"normalized_text\": \"normalizedText\", \"start_time\": 9, \"end_time\": 7, \"confidence\": 0}]}, \"word_alternatives\": [{\"start_time\": 9, \"end_time\": 7, \"alternatives\": [{\"confidence\": 0, \"word\": \"word\"}]}], \"end_of_utterance\": \"end_of_data\"}], \"result_index\": 11, \"speaker_labels\": [{\"from\": 4, \"to\": 2, \"speaker\": 7, \"confidence\": 10, \"final\": true}], \"processing_metrics\": {\"processed_audio\": {\"received\": 8, \"seen_by_engine\": 12, \"transcription\": 13, \"speaker_labels\": 13}, \"wall_clock_since_first_byte_received\": 31, \"periodic\": true}, \"audio_metrics\": {\"sampling_interval\": 16, \"accumulated\": {\"final\": true, \"end_time\": 7, \"signal_to_noise_ratio\": 18, \"speech_ratio\": 11, \"high_frequency_loss\": 17, \"direct_current_offset\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"clipping_rate\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"speech_level\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"non_speech_level\": [{\"begin\": 5, \"end\": 3, \"count\": 5}]}}, \"warnings\": [\"warnings\"], \"enriched_results\": {\"transcript\": {\"text\": \"text\", \"timestamp\": {\"from\": 4, \"to\": 2}}, \"status\": \"status\"}}], \"warnings\": [\"warnings\"]}"; String createJobPath = "/v1/recognitions"; server.enqueue( new MockResponse() @@ -449,6 +453,8 @@ public void testCreateJobWOptions() throws Throwable { .events("recognitions.started") .userToken("testString") .resultsTtl(Long.valueOf("26")) + .speechBeginEvent(false) + .enrichments("testString") .languageCustomizationId("testString") .acousticCustomizationId("testString") .baseModelVersion("testString") @@ -500,6 +506,8 @@ public void testCreateJobWOptions() throws Throwable { assertEquals(query.get("events"), "recognitions.started"); assertEquals(query.get("user_token"), "testString"); assertEquals(Long.valueOf(query.get("results_ttl")), Long.valueOf("26")); + assertEquals(Boolean.valueOf(query.get("speech_begin_event")), Boolean.valueOf(false)); + assertEquals(query.get("enrichments"), "testString"); assertEquals(query.get("language_customization_id"), "testString"); assertEquals(query.get("acoustic_customization_id"), "testString"); assertEquals(query.get("base_model_version"), "testString"); @@ -553,7 +561,7 @@ public void testCreateJobNoOptions() throws Throwable { public void testCheckJobsWOptions() throws Throwable { // Register a mock response String mockResponseBody = - "{\"recognitions\": [{\"id\": \"id\", \"status\": \"waiting\", \"created\": \"created\", \"updated\": \"updated\", \"url\": \"url\", \"user_token\": \"userToken\", \"results\": [{\"results\": [{\"final\": true, \"alternatives\": [{\"transcript\": \"transcript\", \"confidence\": 0, \"timestamps\": [[\"timestamps\"]], \"word_confidence\": [[\"wordConfidence\"]]}], \"keywords_result\": {\"mapKey\": [{\"normalized_text\": \"normalizedText\", \"start_time\": 9, \"end_time\": 7, \"confidence\": 0}]}, \"word_alternatives\": [{\"start_time\": 9, \"end_time\": 7, \"alternatives\": [{\"confidence\": 0, \"word\": \"word\"}]}], \"end_of_utterance\": \"end_of_data\"}], \"result_index\": 11, \"speaker_labels\": [{\"from\": 4, \"to\": 2, \"speaker\": 7, \"confidence\": 10, \"final\": true}], \"processing_metrics\": {\"processed_audio\": {\"received\": 8, \"seen_by_engine\": 12, \"transcription\": 13, \"speaker_labels\": 13}, \"wall_clock_since_first_byte_received\": 31, \"periodic\": true}, \"audio_metrics\": {\"sampling_interval\": 16, \"accumulated\": {\"final\": true, \"end_time\": 7, \"signal_to_noise_ratio\": 18, \"speech_ratio\": 11, \"high_frequency_loss\": 17, \"direct_current_offset\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"clipping_rate\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"speech_level\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"non_speech_level\": [{\"begin\": 5, \"end\": 3, \"count\": 5}]}}, \"warnings\": [\"warnings\"]}], \"warnings\": [\"warnings\"]}]}"; + "{\"recognitions\": [{\"id\": \"id\", \"status\": \"waiting\", \"created\": \"created\", \"updated\": \"updated\", \"url\": \"url\", \"user_token\": \"userToken\", \"results\": [{\"results\": [{\"final\": true, \"alternatives\": [{\"transcript\": \"transcript\", \"confidence\": 0, \"timestamps\": [[\"timestamps\"]], \"word_confidence\": [[\"wordConfidence\"]]}], \"keywords_result\": {\"mapKey\": [{\"normalized_text\": \"normalizedText\", \"start_time\": 9, \"end_time\": 7, \"confidence\": 0}]}, \"word_alternatives\": [{\"start_time\": 9, \"end_time\": 7, \"alternatives\": [{\"confidence\": 0, \"word\": \"word\"}]}], \"end_of_utterance\": \"end_of_data\"}], \"result_index\": 11, \"speaker_labels\": [{\"from\": 4, \"to\": 2, \"speaker\": 7, \"confidence\": 10, \"final\": true}], \"processing_metrics\": {\"processed_audio\": {\"received\": 8, \"seen_by_engine\": 12, \"transcription\": 13, \"speaker_labels\": 13}, \"wall_clock_since_first_byte_received\": 31, \"periodic\": true}, \"audio_metrics\": {\"sampling_interval\": 16, \"accumulated\": {\"final\": true, \"end_time\": 7, \"signal_to_noise_ratio\": 18, \"speech_ratio\": 11, \"high_frequency_loss\": 17, \"direct_current_offset\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"clipping_rate\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"speech_level\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"non_speech_level\": [{\"begin\": 5, \"end\": 3, \"count\": 5}]}}, \"warnings\": [\"warnings\"], \"enriched_results\": {\"transcript\": {\"text\": \"text\", \"timestamp\": {\"from\": 4, \"to\": 2}}, \"status\": \"status\"}}], \"warnings\": [\"warnings\"]}]}"; String checkJobsPath = "/v1/recognitions"; server.enqueue( new MockResponse() @@ -598,7 +606,7 @@ public void testCheckJobsWRetries() throws Throwable { public void testCheckJobWOptions() throws Throwable { // Register a mock response String mockResponseBody = - "{\"id\": \"id\", \"status\": \"waiting\", \"created\": \"created\", \"updated\": \"updated\", \"url\": \"url\", \"user_token\": \"userToken\", \"results\": [{\"results\": [{\"final\": true, \"alternatives\": [{\"transcript\": \"transcript\", \"confidence\": 0, \"timestamps\": [[\"timestamps\"]], \"word_confidence\": [[\"wordConfidence\"]]}], \"keywords_result\": {\"mapKey\": [{\"normalized_text\": \"normalizedText\", \"start_time\": 9, \"end_time\": 7, \"confidence\": 0}]}, \"word_alternatives\": [{\"start_time\": 9, \"end_time\": 7, \"alternatives\": [{\"confidence\": 0, \"word\": \"word\"}]}], \"end_of_utterance\": \"end_of_data\"}], \"result_index\": 11, \"speaker_labels\": [{\"from\": 4, \"to\": 2, \"speaker\": 7, \"confidence\": 10, \"final\": true}], \"processing_metrics\": {\"processed_audio\": {\"received\": 8, \"seen_by_engine\": 12, \"transcription\": 13, \"speaker_labels\": 13}, \"wall_clock_since_first_byte_received\": 31, \"periodic\": true}, \"audio_metrics\": {\"sampling_interval\": 16, \"accumulated\": {\"final\": true, \"end_time\": 7, \"signal_to_noise_ratio\": 18, \"speech_ratio\": 11, \"high_frequency_loss\": 17, \"direct_current_offset\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"clipping_rate\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"speech_level\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"non_speech_level\": [{\"begin\": 5, \"end\": 3, \"count\": 5}]}}, \"warnings\": [\"warnings\"]}], \"warnings\": [\"warnings\"]}"; + "{\"id\": \"id\", \"status\": \"waiting\", \"created\": \"created\", \"updated\": \"updated\", \"url\": \"url\", \"user_token\": \"userToken\", \"results\": [{\"results\": [{\"final\": true, \"alternatives\": [{\"transcript\": \"transcript\", \"confidence\": 0, \"timestamps\": [[\"timestamps\"]], \"word_confidence\": [[\"wordConfidence\"]]}], \"keywords_result\": {\"mapKey\": [{\"normalized_text\": \"normalizedText\", \"start_time\": 9, \"end_time\": 7, \"confidence\": 0}]}, \"word_alternatives\": [{\"start_time\": 9, \"end_time\": 7, \"alternatives\": [{\"confidence\": 0, \"word\": \"word\"}]}], \"end_of_utterance\": \"end_of_data\"}], \"result_index\": 11, \"speaker_labels\": [{\"from\": 4, \"to\": 2, \"speaker\": 7, \"confidence\": 10, \"final\": true}], \"processing_metrics\": {\"processed_audio\": {\"received\": 8, \"seen_by_engine\": 12, \"transcription\": 13, \"speaker_labels\": 13}, \"wall_clock_since_first_byte_received\": 31, \"periodic\": true}, \"audio_metrics\": {\"sampling_interval\": 16, \"accumulated\": {\"final\": true, \"end_time\": 7, \"signal_to_noise_ratio\": 18, \"speech_ratio\": 11, \"high_frequency_loss\": 17, \"direct_current_offset\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"clipping_rate\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"speech_level\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"non_speech_level\": [{\"begin\": 5, \"end\": 3, \"count\": 5}]}}, \"warnings\": [\"warnings\"], \"enriched_results\": {\"transcript\": {\"text\": \"text\", \"timestamp\": {\"from\": 4, \"to\": 2}}, \"status\": \"status\"}}], \"warnings\": [\"warnings\"]}"; String checkJobPath = "/v1/recognitions/testString"; server.enqueue( new MockResponse() @@ -2380,6 +2388,64 @@ public void testDeleteUserDataNoOptions() throws Throwable { speechToTextService.deleteUserData(null).execute(); } + // Test the detectLanguage operation with a valid options model parameter + @Test + public void testDetectLanguageWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = + "{\"results\": [{\"language_info\": [{\"confidence\": 10, \"language\": \"language\", \"timestamp\": 9}]}], \"result_index\": 11}"; + String detectLanguagePath = "/v1/detect_language"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the DetectLanguageOptions model + DetectLanguageOptions detectLanguageOptionsModel = + new DetectLanguageOptions.Builder() + .lidConfidence(Float.valueOf("36.0")) + .audio(TestUtilities.createMockStream("This is a mock file.")) + .contentType("application/octet-stream") + .build(); + + // Invoke detectLanguage() with a valid options model and verify the result + Response response = + speechToTextService.detectLanguage(detectLanguageOptionsModel).execute(); + assertNotNull(response); + LanguageDetectionResults responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, detectLanguagePath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(Float.valueOf(query.get("lid_confidence")), Float.valueOf("36.0")); + } + + // Test the detectLanguage operation with and without retries enabled + @Test + public void testDetectLanguageWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testDetectLanguageWOptions(); + + speechToTextService.disableRetries(); + testDetectLanguageWOptions(); + } + + // Test the detectLanguage operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDetectLanguageNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + speechToTextService.detectLanguage(null).execute(); + } + // Perform setup needed before each test method @BeforeMethod public void beforeEachTest() { diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CreateJobOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CreateJobOptionsTest.java index 5ea9b488a5..e4e3c55c2b 100644 --- a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CreateJobOptionsTest.java +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CreateJobOptionsTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020, 2025. + * (C) Copyright IBM Corp. 2020, 2026. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -40,6 +40,8 @@ public void testCreateJobOptions() throws Throwable { .events("recognitions.started") .userToken("testString") .resultsTtl(Long.valueOf("26")) + .speechBeginEvent(false) + .enrichments("testString") .languageCustomizationId("testString") .acousticCustomizationId("testString") .baseModelVersion("testString") @@ -77,6 +79,8 @@ public void testCreateJobOptions() throws Throwable { assertEquals(createJobOptionsModel.events(), "recognitions.started"); assertEquals(createJobOptionsModel.userToken(), "testString"); assertEquals(createJobOptionsModel.resultsTtl(), Long.valueOf("26")); + assertEquals(createJobOptionsModel.speechBeginEvent(), Boolean.valueOf(false)); + assertEquals(createJobOptionsModel.enrichments(), "testString"); assertEquals(createJobOptionsModel.languageCustomizationId(), "testString"); assertEquals(createJobOptionsModel.acousticCustomizationId(), "testString"); assertEquals(createJobOptionsModel.baseModelVersion(), "testString"); diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DetectLanguageOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DetectLanguageOptionsTest.java new file mode 100644 index 0000000000..7a2cc9851d --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DetectLanguageOptionsTest.java @@ -0,0 +1,51 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the DetectLanguageOptions model. */ +public class DetectLanguageOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDetectLanguageOptions() throws Throwable { + DetectLanguageOptions detectLanguageOptionsModel = + new DetectLanguageOptions.Builder() + .lidConfidence(Float.valueOf("36.0")) + .audio(TestUtilities.createMockStream("This is a mock file.")) + .contentType("application/octet-stream") + .build(); + assertEquals(detectLanguageOptionsModel.lidConfidence(), Float.valueOf("36.0")); + assertEquals( + IOUtils.toString(detectLanguageOptionsModel.audio()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(detectLanguageOptionsModel.contentType(), "application/octet-stream"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDetectLanguageOptionsError() throws Throwable { + new DetectLanguageOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/EnrichedResultsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/EnrichedResultsTest.java new file mode 100644 index 0000000000..6f0e7c7636 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/EnrichedResultsTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the EnrichedResults model. */ +public class EnrichedResultsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEnrichedResults() throws Throwable { + EnrichedResults enrichedResultsModel = new EnrichedResults(); + assertNull(enrichedResultsModel.getTranscript()); + assertNull(enrichedResultsModel.getStatus()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/EnrichedResultsTranscriptTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/EnrichedResultsTranscriptTest.java new file mode 100644 index 0000000000..cb0abc6c64 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/EnrichedResultsTranscriptTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the EnrichedResultsTranscript model. */ +public class EnrichedResultsTranscriptTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEnrichedResultsTranscript() throws Throwable { + EnrichedResultsTranscript enrichedResultsTranscriptModel = new EnrichedResultsTranscript(); + assertNull(enrichedResultsTranscriptModel.getText()); + assertNull(enrichedResultsTranscriptModel.getTimestamp()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/EnrichedResultsTranscriptTimestampTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/EnrichedResultsTranscriptTimestampTest.java new file mode 100644 index 0000000000..3ef738df8a --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/EnrichedResultsTranscriptTimestampTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the EnrichedResultsTranscriptTimestamp model. */ +public class EnrichedResultsTranscriptTimestampTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEnrichedResultsTranscriptTimestamp() throws Throwable { + EnrichedResultsTranscriptTimestamp enrichedResultsTranscriptTimestampModel = + new EnrichedResultsTranscriptTimestamp(); + assertNull(enrichedResultsTranscriptTimestampModel.getFrom()); + assertNull(enrichedResultsTranscriptTimestampModel.getTo()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/LanguageDetectionResultTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/LanguageDetectionResultTest.java new file mode 100644 index 0000000000..05eabfeab6 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/LanguageDetectionResultTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the LanguageDetectionResult model. */ +public class LanguageDetectionResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLanguageDetectionResult() throws Throwable { + LanguageDetectionResult languageDetectionResultModel = new LanguageDetectionResult(); + assertNull(languageDetectionResultModel.getLanguageInfo()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/LanguageDetectionResultsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/LanguageDetectionResultsTest.java new file mode 100644 index 0000000000..8fcb3aa149 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/LanguageDetectionResultsTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the LanguageDetectionResults model. */ +public class LanguageDetectionResultsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLanguageDetectionResults() throws Throwable { + LanguageDetectionResults languageDetectionResultsModel = new LanguageDetectionResults(); + assertNull(languageDetectionResultsModel.getResults()); + assertNull(languageDetectionResultsModel.getResultIndex()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/LanguageInfoTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/LanguageInfoTest.java new file mode 100644 index 0000000000..9f824bddfc --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/LanguageInfoTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the LanguageInfo model. */ +public class LanguageInfoTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLanguageInfo() throws Throwable { + LanguageInfo languageInfoModel = new LanguageInfo(); + assertNull(languageInfoModel.getConfidence()); + assertNull(languageInfoModel.getLanguage()); + assertNull(languageInfoModel.getTimestamp()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/RecognizeOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/RecognizeOptionsTest.java index 3495772274..c6a364d0f5 100644 --- a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/RecognizeOptionsTest.java +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/RecognizeOptionsTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020, 2025. + * (C) Copyright IBM Corp. 2020, 2026. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -37,6 +37,7 @@ public void testRecognizeOptions() throws Throwable { .contentType("application/octet-stream") .model("en-US_BroadbandModel") .speechBeginEvent(false) + .enrichments("testString") .languageCustomizationId("testString") .acousticCustomizationId("testString") .baseModelVersion("testString") @@ -69,6 +70,7 @@ public void testRecognizeOptions() throws Throwable { assertEquals(recognizeOptionsModel.contentType(), "application/octet-stream"); assertEquals(recognizeOptionsModel.model(), "en-US_BroadbandModel"); assertEquals(recognizeOptionsModel.speechBeginEvent(), Boolean.valueOf(false)); + assertEquals(recognizeOptionsModel.enrichments(), "testString"); assertEquals(recognizeOptionsModel.languageCustomizationId(), "testString"); assertEquals(recognizeOptionsModel.acousticCustomizationId(), "testString"); assertEquals(recognizeOptionsModel.baseModelVersion(), "testString"); diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResultsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResultsTest.java index d981cf8798..420bd51715 100644 --- a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResultsTest.java +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResultsTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020. + * (C) Copyright IBM Corp. 2020, 2026. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -37,5 +37,6 @@ public void testSpeechRecognitionResults() throws Throwable { assertNull(speechRecognitionResultsModel.getProcessingMetrics()); assertNull(speechRecognitionResultsModel.getAudioMetrics()); assertNull(speechRecognitionResultsModel.getWarnings()); + assertNull(speechRecognitionResultsModel.getEnrichedResults()); } }