Skip to content

Commit 8209b8c

Browse files
google-genai-botcopybara-github
authored andcommitted
feat: Add flat language_codes field to AudioTranscriptionConfig.
FUTURE_COPYBARA_INTEGRATE_REVIEW=#1128 from googleapis:release-please--branches--main 5ffdc79 PiperOrigin-RevId: 951647323
1 parent 547cc5f commit 8209b8c

5 files changed

Lines changed: 35 additions & 122 deletions

File tree

src/main/java/com/google/genai/LiveConverters.java

Lines changed: 4 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -31,46 +31,6 @@ public LiveConverters(ApiClient apiClient) {
3131
this.apiClient = apiClient;
3232
}
3333

34-
@ExcludeFromGeneratedCoverageReport
35-
ObjectNode audioTranscriptionConfigToMldev(JsonNode fromObject, ObjectNode parentObject) {
36-
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
37-
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"languageCodes"}))) {
38-
throw new IllegalArgumentException(
39-
"languageCodes parameter is only supported in Gemini Enterprise Agent Platform mode, not"
40-
+ " in Gemini Developer API mode.");
41-
}
42-
43-
if (Common.getValueByPath(fromObject, new String[] {"languageAuto"}) != null) {
44-
Common.setValueByPath(
45-
toObject,
46-
new String[] {"languageAuto"},
47-
Common.getValueByPath(fromObject, new String[] {"languageAuto"}));
48-
}
49-
50-
if (Common.getValueByPath(fromObject, new String[] {"languageHints"}) != null) {
51-
Common.setValueByPath(
52-
toObject,
53-
new String[] {"languageHints"},
54-
Common.getValueByPath(fromObject, new String[] {"languageHints"}));
55-
}
56-
57-
if (Common.getValueByPath(fromObject, new String[] {"customVocabulary"}) != null) {
58-
Common.setValueByPath(
59-
toObject,
60-
new String[] {"customVocabulary"},
61-
Common.getValueByPath(fromObject, new String[] {"customVocabulary"}));
62-
}
63-
64-
if (Common.getValueByPath(fromObject, new String[] {"adaptationPhrases"}) != null) {
65-
Common.setValueByPath(
66-
toObject,
67-
new String[] {"adaptationPhrases"},
68-
Common.getValueByPath(fromObject, new String[] {"adaptationPhrases"}));
69-
}
70-
71-
return toObject;
72-
}
73-
7434
@ExcludeFromGeneratedCoverageReport
7535
ObjectNode authConfigToMldev(JsonNode fromObject, ObjectNode parentObject) {
7636
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
@@ -926,20 +886,14 @@ ObjectNode liveClientSetupToMldev(JsonNode fromObject, ObjectNode parentObject)
926886
Common.setValueByPath(
927887
toObject,
928888
new String[] {"inputAudioTranscription"},
929-
audioTranscriptionConfigToMldev(
930-
JsonSerializable.toJsonNode(
931-
Common.getValueByPath(fromObject, new String[] {"inputAudioTranscription"})),
932-
toObject));
889+
Common.getValueByPath(fromObject, new String[] {"inputAudioTranscription"}));
933890
}
934891

935892
if (Common.getValueByPath(fromObject, new String[] {"outputAudioTranscription"}) != null) {
936893
Common.setValueByPath(
937894
toObject,
938895
new String[] {"outputAudioTranscription"},
939-
audioTranscriptionConfigToMldev(
940-
JsonSerializable.toJsonNode(
941-
Common.getValueByPath(fromObject, new String[] {"outputAudioTranscription"})),
942-
toObject));
896+
Common.getValueByPath(fromObject, new String[] {"outputAudioTranscription"}));
943897
}
944898

945899
if (Common.getValueByPath(fromObject, new String[] {"proactivity"}) != null) {
@@ -1214,20 +1168,14 @@ ObjectNode liveConnectConfigToMldev(JsonNode fromObject, ObjectNode parentObject
12141168
Common.setValueByPath(
12151169
parentObject,
12161170
new String[] {"setup", "inputAudioTranscription"},
1217-
audioTranscriptionConfigToMldev(
1218-
JsonSerializable.toJsonNode(
1219-
Common.getValueByPath(fromObject, new String[] {"inputAudioTranscription"})),
1220-
toObject));
1171+
Common.getValueByPath(fromObject, new String[] {"inputAudioTranscription"}));
12211172
}
12221173

12231174
if (Common.getValueByPath(fromObject, new String[] {"outputAudioTranscription"}) != null) {
12241175
Common.setValueByPath(
12251176
parentObject,
12261177
new String[] {"setup", "outputAudioTranscription"},
1227-
audioTranscriptionConfigToMldev(
1228-
JsonSerializable.toJsonNode(
1229-
Common.getValueByPath(fromObject, new String[] {"outputAudioTranscription"})),
1230-
toObject));
1178+
Common.getValueByPath(fromObject, new String[] {"outputAudioTranscription"}));
12311179
}
12321180

12331181
if (Common.getValueByPath(fromObject, new String[] {"realtimeInputConfig"}) != null) {

src/main/java/com/google/genai/TokensConverters.java

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -31,46 +31,6 @@ public TokensConverters(ApiClient apiClient) {
3131
this.apiClient = apiClient;
3232
}
3333

34-
@ExcludeFromGeneratedCoverageReport
35-
ObjectNode audioTranscriptionConfigToMldev(JsonNode fromObject, ObjectNode parentObject) {
36-
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
37-
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"languageCodes"}))) {
38-
throw new IllegalArgumentException(
39-
"languageCodes parameter is only supported in Gemini Enterprise Agent Platform mode, not"
40-
+ " in Gemini Developer API mode.");
41-
}
42-
43-
if (Common.getValueByPath(fromObject, new String[] {"languageAuto"}) != null) {
44-
Common.setValueByPath(
45-
toObject,
46-
new String[] {"languageAuto"},
47-
Common.getValueByPath(fromObject, new String[] {"languageAuto"}));
48-
}
49-
50-
if (Common.getValueByPath(fromObject, new String[] {"languageHints"}) != null) {
51-
Common.setValueByPath(
52-
toObject,
53-
new String[] {"languageHints"},
54-
Common.getValueByPath(fromObject, new String[] {"languageHints"}));
55-
}
56-
57-
if (Common.getValueByPath(fromObject, new String[] {"customVocabulary"}) != null) {
58-
Common.setValueByPath(
59-
toObject,
60-
new String[] {"customVocabulary"},
61-
Common.getValueByPath(fromObject, new String[] {"customVocabulary"}));
62-
}
63-
64-
if (Common.getValueByPath(fromObject, new String[] {"adaptationPhrases"}) != null) {
65-
Common.setValueByPath(
66-
toObject,
67-
new String[] {"adaptationPhrases"},
68-
Common.getValueByPath(fromObject, new String[] {"adaptationPhrases"}));
69-
}
70-
71-
return toObject;
72-
}
73-
7434
@ExcludeFromGeneratedCoverageReport
7535
ObjectNode authConfigToMldev(JsonNode fromObject, ObjectNode parentObject) {
7636
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
@@ -479,20 +439,14 @@ ObjectNode liveConnectConfigToMldev(JsonNode fromObject, ObjectNode parentObject
479439
Common.setValueByPath(
480440
parentObject,
481441
new String[] {"setup", "inputAudioTranscription"},
482-
audioTranscriptionConfigToMldev(
483-
JsonSerializable.toJsonNode(
484-
Common.getValueByPath(fromObject, new String[] {"inputAudioTranscription"})),
485-
toObject));
442+
Common.getValueByPath(fromObject, new String[] {"inputAudioTranscription"}));
486443
}
487444

488445
if (Common.getValueByPath(fromObject, new String[] {"outputAudioTranscription"}) != null) {
489446
Common.setValueByPath(
490447
parentObject,
491448
new String[] {"setup", "outputAudioTranscription"},
492-
audioTranscriptionConfigToMldev(
493-
JsonSerializable.toJsonNode(
494-
Common.getValueByPath(fromObject, new String[] {"outputAudioTranscription"})),
495-
toObject));
449+
Common.getValueByPath(fromObject, new String[] {"outputAudioTranscription"}));
496450
}
497451

498452
if (Common.getValueByPath(fromObject, new String[] {"realtimeInputConfig"}) != null) {

src/main/java/com/google/genai/types/AudioTranscriptionConfig.java

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,24 @@
3232
@AutoValue
3333
@JsonDeserialize(builder = AudioTranscriptionConfig.Builder.class)
3434
public abstract class AudioTranscriptionConfig extends JsonSerializable {
35-
/** Deprecated: use LanguageAuto or LanguageHints instead. */
35+
/**
36+
* BCP-47 language codes providing hints about the languages present in the audio. If omitted or
37+
* empty, defaults to automatic language detection.
38+
*/
3639
@JsonProperty("languageCodes")
3740
public abstract Optional<List<String>> languageCodes();
3841

39-
/** The model will detect the language automatically. Do not use together with LanguageHints. */
42+
/**
43+
* Deprecated: Auto-detection is now the default when language_codes is omitted. This field will
44+
* be removed in a future version.
45+
*/
4046
@JsonProperty("languageAuto")
4147
public abstract Optional<LanguageAuto> languageAuto();
4248

43-
/** Specifies one or more languages in the audio. Do not use together with LanguageAuto. */
49+
/**
50+
* Deprecated: Use top-level language_codes instead. This field will be removed in a future
51+
* version.
52+
*/
4453
@JsonProperty("languageHints")
4554
public abstract Optional<LanguageHints> languageHints();
4655

@@ -79,15 +88,17 @@ private static Builder create() {
7988
/**
8089
* Setter for languageCodes.
8190
*
82-
* <p>languageCodes: Deprecated: use LanguageAuto or LanguageHints instead.
91+
* <p>languageCodes: BCP-47 language codes providing hints about the languages present in the
92+
* audio. If omitted or empty, defaults to automatic language detection.
8393
*/
8494
@JsonProperty("languageCodes")
8595
public abstract Builder languageCodes(List<String> languageCodes);
8696

8797
/**
8898
* Setter for languageCodes.
8999
*
90-
* <p>languageCodes: Deprecated: use LanguageAuto or LanguageHints instead.
100+
* <p>languageCodes: BCP-47 language codes providing hints about the languages present in the
101+
* audio. If omitted or empty, defaults to automatic language detection.
91102
*/
92103
@CanIgnoreReturnValue
93104
public Builder languageCodes(String... languageCodes) {
@@ -107,17 +118,17 @@ public Builder clearLanguageCodes() {
107118
/**
108119
* Setter for languageAuto.
109120
*
110-
* <p>languageAuto: The model will detect the language automatically. Do not use together with
111-
* LanguageHints.
121+
* <p>languageAuto: Deprecated: Auto-detection is now the default when language_codes is
122+
* omitted. This field will be removed in a future version.
112123
*/
113124
@JsonProperty("languageAuto")
114125
public abstract Builder languageAuto(LanguageAuto languageAuto);
115126

116127
/**
117128
* Setter for languageAuto builder.
118129
*
119-
* <p>languageAuto: The model will detect the language automatically. Do not use together with
120-
* LanguageHints.
130+
* <p>languageAuto: Deprecated: Auto-detection is now the default when language_codes is
131+
* omitted. This field will be removed in a future version.
121132
*/
122133
@CanIgnoreReturnValue
123134
public Builder languageAuto(LanguageAuto.Builder languageAutoBuilder) {
@@ -137,17 +148,17 @@ public Builder clearLanguageAuto() {
137148
/**
138149
* Setter for languageHints.
139150
*
140-
* <p>languageHints: Specifies one or more languages in the audio. Do not use together with
141-
* LanguageAuto.
151+
* <p>languageHints: Deprecated: Use top-level language_codes instead. This field will be
152+
* removed in a future version.
142153
*/
143154
@JsonProperty("languageHints")
144155
public abstract Builder languageHints(LanguageHints languageHints);
145156

146157
/**
147158
* Setter for languageHints builder.
148159
*
149-
* <p>languageHints: Specifies one or more languages in the audio. Do not use together with
150-
* LanguageAuto.
160+
* <p>languageHints: Deprecated: Use top-level language_codes instead. This field will be
161+
* removed in a future version.
151162
*/
152163
@CanIgnoreReturnValue
153164
public Builder languageHints(LanguageHints.Builder languageHintsBuilder) {

src/main/java/com/google/genai/types/LanguageAuto.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import com.google.auto.value.AutoValue;
2424
import com.google.genai.JsonSerializable;
2525

26-
/** Indicates the language of the audio should be automatically detected. */
26+
/** Deprecated: Language auto-detection is now the default when language_codes is omitted. */
2727
@AutoValue
2828
@JsonDeserialize(builder = LanguageAuto.Builder.class)
2929
public abstract class LanguageAuto extends JsonSerializable {

src/main/java/com/google/genai/types/LanguageHints.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@
2828
import java.util.List;
2929
import java.util.Optional;
3030

31-
/** Provides hints to the model about possible languages present in the audio. */
31+
/** Deprecated: Use AudioTranscriptionConfig.language_codes instead. */
3232
@AutoValue
3333
@JsonDeserialize(builder = LanguageHints.Builder.class)
3434
public abstract class LanguageHints extends JsonSerializable {
35-
/** BCP-47 language codes. At least one must be specified. */
35+
/** Deprecated. BCP-47 language codes. */
3636
@JsonProperty("languageCodes")
3737
public abstract Optional<List<String>> languageCodes();
3838

@@ -57,15 +57,15 @@ private static Builder create() {
5757
/**
5858
* Setter for languageCodes.
5959
*
60-
* <p>languageCodes: BCP-47 language codes. At least one must be specified.
60+
* <p>languageCodes: Deprecated. BCP-47 language codes.
6161
*/
6262
@JsonProperty("languageCodes")
6363
public abstract Builder languageCodes(List<String> languageCodes);
6464

6565
/**
6666
* Setter for languageCodes.
6767
*
68-
* <p>languageCodes: BCP-47 language codes. At least one must be specified.
68+
* <p>languageCodes: Deprecated. BCP-47 language codes.
6969
*/
7070
@CanIgnoreReturnValue
7171
public Builder languageCodes(String... languageCodes) {

0 commit comments

Comments
 (0)