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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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<String, Object> parameters;

protected DtmfCommandInfo() {}

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

/**
* Gets the parameters.
*
* <p>Parameters specified by the command type.
*
* @return the parameters
*/
public Map<String, Object> getParameters() {
return parameters;
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -31,7 +31,9 @@
* RuntimeResponseGenericRuntimeResponseTypeSearch -
* RuntimeResponseGenericRuntimeResponseTypeUserDefined -
* RuntimeResponseGenericRuntimeResponseTypeVideo - RuntimeResponseGenericRuntimeResponseTypeAudio -
* RuntimeResponseGenericRuntimeResponseTypeIframe - RuntimeResponseGenericRuntimeResponseTypeDate
* RuntimeResponseGenericRuntimeResponseTypeIframe - RuntimeResponseGenericRuntimeResponseTypeDate -
* RuntimeResponseGenericRuntimeResponseTypeDtmf -
* RuntimeResponseGenericRuntimeResponseTypeEndSession
*/
public class RuntimeResponseGeneric extends GenericModel {
@SuppressWarnings("unused")
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -134,6 +139,9 @@ public interface Preference {
@SerializedName("image_url")
protected String imageUrl;

@SerializedName("command_info")
protected DtmfCommandInfo commandInfo;

protected RuntimeResponseGeneric() {}

/**
Expand Down Expand Up @@ -470,4 +478,13 @@ public Map<String, Object> channelOptions() {
public String imageUrl() {
return imageUrl;
}

/**
* Gets the commandInfo.
*
* @return the commandInfo
*/
public DtmfCommandInfo commandInfo() {
return commandInfo;
}
}
Original file line number Diff line number Diff line change
@@ -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() {}
}
Original file line number Diff line number Diff line change
@@ -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() {}
}
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -60,6 +60,7 @@ public void testCompleteItem() throws Throwable {
assertNull(completeItemModel.userDefined());
assertNull(completeItemModel.channelOptions());
assertNull(completeItemModel.imageUrl());
assertNull(completeItemModel.commandInfo());
assertNull(completeItemModel.getStreamingMetadata());
}
}
Original file line number Diff line number Diff line change
@@ -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<String, InputStream> mockStreamMap = TestUtilities.createMockStreamMap();
final List<FileWithMetadata> mockListFileWithMetadata =
TestUtilities.creatMockListFileWithMetadata();

@Test
public void testDtmfCommandInfo() throws Throwable {
DtmfCommandInfo dtmfCommandInfoModel = new DtmfCommandInfo();
assertNull(dtmfCommandInfoModel.getType());
assertNull(dtmfCommandInfoModel.getParameters());
}
}
Original file line number Diff line number Diff line change
@@ -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<String, InputStream> mockStreamMap = TestUtilities.createMockStreamMap();
final List<FileWithMetadata> mockListFileWithMetadata =
TestUtilities.creatMockListFileWithMetadata();

@Test
public void testRuntimeResponseGenericRuntimeResponseTypeDtmf() throws Throwable {
RuntimeResponseGenericRuntimeResponseTypeDtmf
runtimeResponseGenericRuntimeResponseTypeDtmfModel =
new RuntimeResponseGenericRuntimeResponseTypeDtmf();
assertNull(runtimeResponseGenericRuntimeResponseTypeDtmfModel.responseType());
assertNull(runtimeResponseGenericRuntimeResponseTypeDtmfModel.commandInfo());
assertNull(runtimeResponseGenericRuntimeResponseTypeDtmfModel.channels());
}
}
Original file line number Diff line number Diff line change
@@ -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<String, InputStream> mockStreamMap = TestUtilities.createMockStreamMap();
final List<FileWithMetadata> mockListFileWithMetadata =
TestUtilities.creatMockListFileWithMetadata();

@Test
public void testRuntimeResponseGenericRuntimeResponseTypeEndSession() throws Throwable {
RuntimeResponseGenericRuntimeResponseTypeEndSession
runtimeResponseGenericRuntimeResponseTypeEndSessionModel =
new RuntimeResponseGenericRuntimeResponseTypeEndSession();
assertNull(runtimeResponseGenericRuntimeResponseTypeEndSessionModel.responseType());
assertNull(runtimeResponseGenericRuntimeResponseTypeEndSessionModel.channelOptions());
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -447,6 +449,9 @@ public ServiceCall<SpeechRecognitionResults> 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()));
Expand Down Expand Up @@ -776,6 +781,12 @@ public ServiceCall<RecognitionJob> 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()));
Expand Down Expand Up @@ -2801,4 +2812,43 @@ public ServiceCall<Void> deleteUserData(DeleteUserDataOptions deleteUserDataOpti
ResponseConverter<Void> responseConverter = ResponseConverterUtils.getVoid();
return createServiceCall(builder.build(), responseConverter);
}

/**
* Spoken language identification.
*
* <p>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<LanguageDetectionResults> 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<String, String> sdkHeaders =
SdkCommon.getSdkHeaders("speech_to_text", "v1", "detectLanguage");
for (Entry<String, String> 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<LanguageDetectionResults> responseConverter =
ResponseConverterUtils.getValue(
new com.google.gson.reflect.TypeToken<LanguageDetectionResults>() {}.getType());
return createServiceCall(builder.build(), responseConverter);
}
}
Loading