Skip to content

Commit 56755c6

Browse files
feat(stt): new params
New param list: smartFormattingVersion, force, mappingOnly
1 parent fb139e7 commit 56755c6

15 files changed

+365
-101
lines changed

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

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* (C) Copyright IBM Corp. 2016, 2023.
2+
* (C) Copyright IBM Corp. 2024.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
55
* the License. You may obtain a copy of the License at
@@ -12,7 +12,7 @@
1212
*/
1313

1414
/*
15-
* IBM OpenAPI SDK Code Generator Version: 3.64.1-cee95189-20230124-211647
15+
* IBM OpenAPI SDK Code Generator Version: 3.85.0-75c38f8f-20240206-210220
1616
*/
1717

1818
package com.ibm.watson.speech_to_text.v1;
@@ -482,6 +482,10 @@ public ServiceCall<SpeechRecognitionResults> recognize(RecognizeOptions recogniz
482482
if (recognizeOptions.smartFormatting() != null) {
483483
builder.query("smart_formatting", String.valueOf(recognizeOptions.smartFormatting()));
484484
}
485+
if (recognizeOptions.smartFormattingVersion() != null) {
486+
builder.query(
487+
"smart_formatting_version", String.valueOf(recognizeOptions.smartFormattingVersion()));
488+
}
485489
if (recognizeOptions.speakerLabels() != null) {
486490
builder.query("speaker_labels", String.valueOf(recognizeOptions.speakerLabels()));
487491
}
@@ -798,6 +802,10 @@ public ServiceCall<RecognitionJob> createJob(CreateJobOptions createJobOptions)
798802
if (createJobOptions.smartFormatting() != null) {
799803
builder.query("smart_formatting", String.valueOf(createJobOptions.smartFormatting()));
800804
}
805+
if (createJobOptions.smartFormattingVersion() != null) {
806+
builder.query(
807+
"smart_formatting_version", String.valueOf(createJobOptions.smartFormattingVersion()));
808+
}
801809
if (createJobOptions.speakerLabels() != null) {
802810
builder.query("speaker_labels", String.valueOf(createJobOptions.speakerLabels()));
803811
}
@@ -1184,10 +1192,16 @@ public ServiceCall<Void> deleteLanguageModel(
11841192
* cannot accept subsequent training requests or requests to add new resources until the existing
11851193
* request completes.
11861194
*
1187-
* <p>**See also:** * [Train the custom language
1195+
* <p>For custom models that are based on improved base language models, training also performs an
1196+
* automatic upgrade to a newer version of the base model. You do not need to use the [Upgrade a
1197+
* custom language model](#upgradelanguagemodel) method to perform the upgrade.
1198+
*
1199+
* <p>**See also:** * [Language support for
1200+
* customization](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-custom-support) *
1201+
* [Train the custom language
11881202
* model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-languageCreate#trainModel-language)
1189-
* * [Language support for
1190-
* customization](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-custom-support)
1203+
* * [Upgrading custom language models that are based on improved next-generation
1204+
* models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-custom-upgrade#custom-upgrade-language-ng)
11911205
*
11921206
* <p>### Training failures
11931207
*
@@ -1229,6 +1243,9 @@ public ServiceCall<TrainingResponse> trainLanguageModel(
12291243
if (trainLanguageModelOptions.strict() != null) {
12301244
builder.query("strict", String.valueOf(trainLanguageModelOptions.strict()));
12311245
}
1246+
if (trainLanguageModelOptions.force() != null) {
1247+
builder.query("force", String.valueOf(trainLanguageModelOptions.force()));
1248+
}
12321249
ResponseConverter<TrainingResponse> responseConverter =
12331250
ResponseConverterUtils.getValue(
12341251
new com.google.gson.reflect.TypeToken<TrainingResponse>() {}.getType());
@@ -1291,10 +1308,16 @@ public ServiceCall<Void> resetLanguageModel(ResetLanguageModelOptions resetLangu
12911308
* complete, the model resumes the status that it had prior to upgrade. The service cannot accept
12921309
* subsequent requests for the model until the upgrade completes.
12931310
*
1294-
* <p>**See also:** * [Upgrading a custom language
1311+
* <p>For custom models that are based on improved base language models, the [Train a custom
1312+
* language model](#trainlanguagemodel) method also performs an automatic upgrade to a newer
1313+
* version of the base model. You do not need to use the upgrade method.
1314+
*
1315+
* <p>**See also:** * [Language support for
1316+
* customization](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-custom-support) *
1317+
* [Upgrading a custom language
12951318
* model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-custom-upgrade#custom-upgrade-language)
1296-
* * [Language support for
1297-
* customization](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-custom-support).
1319+
* * [Upgrading custom language models that are based on improved next-generation
1320+
* models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-custom-upgrade#custom-upgrade-language-ng).
12981321
*
12991322
* @param upgradeLanguageModelOptions the {@link UpgradeLanguageModelOptions} containing the
13001323
* options for the call
@@ -1436,10 +1459,10 @@ public ServiceCall<Void> addCorpus(AddCorpusOptions addCorpusOptions) {
14361459
if (addCorpusOptions.allowOverwrite() != null) {
14371460
builder.query("allow_overwrite", String.valueOf(addCorpusOptions.allowOverwrite()));
14381461
}
1439-
1462+
14401463
// hand edit replacement for corpus file serialization
14411464
builder.body(RequestUtils.inputStreamBody(addCorpusOptions.corpusFile(), "text/plain"));
1442-
1465+
14431466
ResponseConverter<Void> responseConverter = ResponseConverterUtils.getVoid();
14441467
return createServiceCall(builder.build(), responseConverter);
14451468
}
@@ -1601,7 +1624,13 @@ public ServiceCall<Words> listWords(ListWordsOptions listWordsOptions) {
16011624
* custom model that is based on a previous-generation model_, if you omit the `sounds_like`
16021625
* field, the service attempts to set the field to its pronunciation of the word. It cannot
16031626
* generate a pronunciation for all words, so you must review the word's definition to ensure that
1604-
* it is complete and valid.
1627+
* it is complete and valid. * The `mapping_only` field provides parameter for custom words. You
1628+
* can use the 'mapping_only' key in custom words as a form of post processing. This key parameter
1629+
* has a boolean value to determine whether 'sounds_like' (for non-Japanese models) or word (for
1630+
* Japanese) is not used for the model fine-tuning, but for the replacement for 'display_as'. This
1631+
* feature helps you when you use custom words exclusively to map 'sounds_like' (or word) to
1632+
* 'display_as' value. When you use custom words solely for post-processing purposes that does not
1633+
* need fine-tuning.
16051634
*
16061635
* <p>If you add a custom word that already exists in the words resource for the custom model, the
16071636
* new definition overwrites the existing data for the word. If the service encounters an error
@@ -1733,6 +1762,12 @@ public ServiceCall<Void> addWord(AddWordOptions addWordOptions) {
17331762
if (addWordOptions.word() != null) {
17341763
contentJson.addProperty("word", addWordOptions.word());
17351764
}
1765+
if (addWordOptions.mappingOnly() != null) {
1766+
contentJson.add(
1767+
"mapping_only",
1768+
com.ibm.cloud.sdk.core.util.GsonSingleton.getGson()
1769+
.toJsonTree(addWordOptions.mappingOnly()));
1770+
}
17361771
if (addWordOptions.soundsLike() != null) {
17371772
contentJson.add(
17381773
"sounds_like",

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

Lines changed: 61 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* (C) Copyright IBM Corp. 2018, 2023.
2+
* (C) Copyright IBM Corp. 2024.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
55
* the License. You may obtain a copy of the License at
@@ -22,6 +22,7 @@ public class AddWordOptions extends GenericModel {
2222
protected String customizationId;
2323
protected String wordName;
2424
protected String word;
25+
protected List<String> mappingOnly;
2526
protected List<String> soundsLike;
2627
protected String displayAs;
2728

@@ -30,6 +31,7 @@ public static class Builder {
3031
private String customizationId;
3132
private String wordName;
3233
private String word;
34+
private List<String> mappingOnly;
3335
private List<String> soundsLike;
3436
private String displayAs;
3537

@@ -42,6 +44,7 @@ private Builder(AddWordOptions addWordOptions) {
4244
this.customizationId = addWordOptions.customizationId;
4345
this.wordName = addWordOptions.wordName;
4446
this.word = addWordOptions.word;
47+
this.mappingOnly = addWordOptions.mappingOnly;
4548
this.soundsLike = addWordOptions.soundsLike;
4649
this.displayAs = addWordOptions.displayAs;
4750
}
@@ -70,9 +73,24 @@ public AddWordOptions build() {
7073
}
7174

7275
/**
73-
* Adds an soundsLike to soundsLike.
76+
* Adds a new element to mappingOnly.
7477
*
75-
* @param soundsLike the new soundsLike
78+
* @param mappingOnly the new element to be added
79+
* @return the AddWordOptions builder
80+
*/
81+
public Builder addMappingOnly(String mappingOnly) {
82+
com.ibm.cloud.sdk.core.util.Validator.notNull(mappingOnly, "mappingOnly cannot be null");
83+
if (this.mappingOnly == null) {
84+
this.mappingOnly = new ArrayList<String>();
85+
}
86+
this.mappingOnly.add(mappingOnly);
87+
return this;
88+
}
89+
90+
/**
91+
* Adds a new element to soundsLike.
92+
*
93+
* @param soundsLike the new element to be added
7694
* @return the AddWordOptions builder
7795
*/
7896
public Builder addSoundsLike(String soundsLike) {
@@ -117,6 +135,17 @@ public Builder word(String word) {
117135
return this;
118136
}
119137

138+
/**
139+
* Set the mappingOnly. Existing mappingOnly will be replaced.
140+
*
141+
* @param mappingOnly the mappingOnly
142+
* @return the AddWordOptions builder
143+
*/
144+
public Builder mappingOnly(List<String> mappingOnly) {
145+
this.mappingOnly = mappingOnly;
146+
return this;
147+
}
148+
120149
/**
121150
* Set the soundsLike. Existing soundsLike will be replaced.
122151
*
@@ -149,6 +178,7 @@ protected AddWordOptions(Builder builder) {
149178
customizationId = builder.customizationId;
150179
wordName = builder.wordName;
151180
word = builder.word;
181+
mappingOnly = builder.mappingOnly;
152182
soundsLike = builder.soundsLike;
153183
displayAs = builder.displayAs;
154184
}
@@ -178,10 +208,11 @@ public String customizationId() {
178208
/**
179209
* Gets the wordName.
180210
*
181-
* <p>The custom word that is to be added to or updated in the custom language model. Do not
182-
* include spaces in the word. Use a `-` (dash) or `_` (underscore) to connect the tokens of
183-
* compound words. URL-encode the word if it includes non-ASCII characters. For more information,
184-
* see [Character
211+
* <p>The custom word that is to be added to or updated in the custom language model. Do not use
212+
* characters that need to be URL-encoded, for example, spaces, slashes, backslashes, colons,
213+
* ampersands, double quotes, plus signs, equals signs, or question marks. Use a `-` (dash) or `_`
214+
* (underscore) to connect the tokens of compound words. URL-encode the word if it includes
215+
* non-ASCII characters. For more information, see [Character
185216
* encoding](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords#charEncoding).
186217
*
187218
* @return the wordName
@@ -194,8 +225,11 @@ public String wordName() {
194225
* Gets the word.
195226
*
196227
* <p>For the [Add custom words](#addwords) method, you must specify the custom word that is to be
197-
* added to or updated in the custom model. Do not include spaces in the word. Use a `-` (dash) or
198-
* `_` (underscore) to connect the tokens of compound words.
228+
* added to or updated in the custom model. Do not use characters that need to be URL-encoded, for
229+
* example, spaces, slashes, backslashes, colons, ampersands, double quotes, plus signs, equals
230+
* signs, or question marks. Use a `-` (dash) or `_` (underscore) to connect the tokens of
231+
* compound words. A Japanese custom word can include at most 25 characters, not including leading
232+
* or trailing spaces.
199233
*
200234
* <p>Omit this parameter for the [Add a custom word](#addword) method.
201235
*
@@ -205,6 +239,22 @@ public String word() {
205239
return word;
206240
}
207241

242+
/**
243+
* Gets the mappingOnly.
244+
*
245+
* <p>Parameter for custom words. You can use the 'mapping_only' key in custom words as a form of
246+
* post processing. This key parameter has a boolean value to determine whether 'sounds_like' (for
247+
* non-Japanese models) or word (for Japanese) is not used for the model fine-tuning, but for the
248+
* replacement for 'display_as'. This feature helps you when you use custom words exclusively to
249+
* map 'sounds_like' (or word) to 'display_as' value. When you use custom words solely for
250+
* post-processing purposes that does not need fine-tuning.
251+
*
252+
* @return the mappingOnly
253+
*/
254+
public List<String> mappingOnly() {
255+
return mappingOnly;
256+
}
257+
208258
/**
209259
* Gets the soundsLike.
210260
*
@@ -218,7 +268,8 @@ public String word() {
218268
* vocabulary.
219269
*
220270
* <p>A word can have at most five sounds-like pronunciations. A pronunciation can include at most
221-
* 40 characters not including spaces.
271+
* 40 characters, not including leading or trailing spaces. A Japanese pronunciation can include
272+
* at most 25 characters, not including leading or trailing spaces.
222273
*
223274
* @return the soundsLike
224275
*/

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

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* (C) Copyright IBM Corp. 2018, 2023.
2+
* (C) Copyright IBM Corp. 2024.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
55
* the License. You may obtain a copy of the License at
@@ -229,6 +229,7 @@ public interface Events {
229229
protected Boolean timestamps;
230230
protected Boolean profanityFilter;
231231
protected Boolean smartFormatting;
232+
protected Boolean smartFormattingVersion;
232233
protected Boolean speakerLabels;
233234
protected String grammarName;
234235
protected Boolean redaction;
@@ -264,6 +265,7 @@ public static class Builder {
264265
private Boolean timestamps;
265266
private Boolean profanityFilter;
266267
private Boolean smartFormatting;
268+
private Boolean smartFormattingVersion;
267269
private Boolean speakerLabels;
268270
private String grammarName;
269271
private Boolean redaction;
@@ -303,6 +305,7 @@ private Builder(CreateJobOptions createJobOptions) {
303305
this.timestamps = createJobOptions.timestamps;
304306
this.profanityFilter = createJobOptions.profanityFilter;
305307
this.smartFormatting = createJobOptions.smartFormatting;
308+
this.smartFormattingVersion = createJobOptions.smartFormattingVersion;
306309
this.speakerLabels = createJobOptions.speakerLabels;
307310
this.grammarName = createJobOptions.grammarName;
308311
this.redaction = createJobOptions.redaction;
@@ -339,9 +342,9 @@ public CreateJobOptions build() {
339342
}
340343

341344
/**
342-
* Adds an keyword to keywords.
345+
* Adds a new element to keywords.
343346
*
344-
* @param keyword the new keyword
347+
* @param keyword the new element to be added
345348
* @return the CreateJobOptions builder
346349
*/
347350
public Builder addKeyword(String keyword) {
@@ -573,6 +576,17 @@ public Builder smartFormatting(Boolean smartFormatting) {
573576
return this;
574577
}
575578

579+
/**
580+
* Set the smartFormattingVersion.
581+
*
582+
* @param smartFormattingVersion the smartFormattingVersion
583+
* @return the CreateJobOptions builder
584+
*/
585+
public Builder smartFormattingVersion(Boolean smartFormattingVersion) {
586+
this.smartFormattingVersion = smartFormattingVersion;
587+
return this;
588+
}
589+
576590
/**
577591
* Set the speakerLabels.
578592
*
@@ -742,6 +756,7 @@ protected CreateJobOptions(Builder builder) {
742756
timestamps = builder.timestamps;
743757
profanityFilter = builder.profanityFilter;
744758
smartFormatting = builder.smartFormatting;
759+
smartFormattingVersion = builder.smartFormattingVersion;
745760
speakerLabels = builder.speakerLabels;
746761
grammarName = builder.grammarName;
747762
redaction = builder.redaction;
@@ -1099,6 +1114,18 @@ public Boolean smartFormatting() {
10991114
return smartFormatting;
11001115
}
11011116

1117+
/**
1118+
* Gets the smartFormattingVersion.
1119+
*
1120+
* <p>Smart formatting version is for next-generation models and that is supported in US English,
1121+
* Brazilian Portuguese, French and German languages.
1122+
*
1123+
* @return the smartFormattingVersion
1124+
*/
1125+
public Boolean smartFormattingVersion() {
1126+
return smartFormattingVersion;
1127+
}
1128+
11021129
/**
11031130
* Gets the speakerLabels.
11041131
*

0 commit comments

Comments
 (0)