diff --git a/src/main/java/com/google/genai/Batches.java b/src/main/java/com/google/genai/Batches.java index d5cf780500e..f1b78c905f7 100644 --- a/src/main/java/com/google/genai/Batches.java +++ b/src/main/java/com/google/genai/Batches.java @@ -64,6 +64,53 @@ public Batches(ApiClient apiClient) { this.apiClient = apiClient; } + @ExcludeFromGeneratedCoverageReport + ObjectNode audioTranscriptionConfigToMldev(JsonNode fromObject, ObjectNode parentObject) { + ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode(); + if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"languageCodes"}))) { + throw new IllegalArgumentException( + "languageCodes parameter is only supported in Gemini Enterprise Agent Platform mode, not" + + " in Gemini Developer API mode."); + } + + if (Common.getValueByPath(fromObject, new String[] {"languageAuto"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"languageAuto"}, + Common.getValueByPath(fromObject, new String[] {"languageAuto"})); + } + + if (Common.getValueByPath(fromObject, new String[] {"languageHints"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"languageHints"}, + Common.getValueByPath(fromObject, new String[] {"languageHints"})); + } + + if (Common.getValueByPath(fromObject, new String[] {"adaptationPhrases"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"adaptationPhrases"}, + Common.getValueByPath(fromObject, new String[] {"adaptationPhrases"})); + } + + if (Common.getValueByPath(fromObject, new String[] {"wordTimestamp"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"wordTimestamp"}, + Common.getValueByPath(fromObject, new String[] {"wordTimestamp"})); + } + + if (Common.getValueByPath(fromObject, new String[] {"diarization"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"diarization"}, + Common.getValueByPath(fromObject, new String[] {"diarization"})); + } + + return toObject; + } + @ExcludeFromGeneratedCoverageReport ObjectNode authConfigToMldev(JsonNode fromObject, ObjectNode parentObject) { ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode(); @@ -1430,6 +1477,16 @@ ObjectNode generateContentConfigToMldev( Common.getValueByPath(fromObject, new String[] {"serviceTier"})); } + if (Common.getValueByPath(fromObject, new String[] {"audioTranscriptionConfig"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"audioTranscriptionConfig"}, + audioTranscriptionConfigToMldev( + JsonSerializable.toJsonNode( + Common.getValueByPath(fromObject, new String[] {"audioTranscriptionConfig"})), + toObject)); + } + return toObject; } @@ -1966,6 +2023,13 @@ ObjectNode partToMldev(JsonNode fromObject, ObjectNode parentObject) { Common.getValueByPath(fromObject, new String[] {"partMetadata"})); } + if (Common.getValueByPath(fromObject, new String[] {"audioTranscription"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"audioTranscription"}, + Common.getValueByPath(fromObject, new String[] {"audioTranscription"})); + } + return toObject; } diff --git a/src/main/java/com/google/genai/Caches.java b/src/main/java/com/google/genai/Caches.java index ca3b25b67e4..2ff1752daee 100644 --- a/src/main/java/com/google/genai/Caches.java +++ b/src/main/java/com/google/genai/Caches.java @@ -959,6 +959,13 @@ ObjectNode partToMldev(JsonNode fromObject, ObjectNode parentObject) { Common.getValueByPath(fromObject, new String[] {"partMetadata"})); } + if (Common.getValueByPath(fromObject, new String[] {"audioTranscription"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"audioTranscription"}, + Common.getValueByPath(fromObject, new String[] {"audioTranscription"})); + } + return toObject; } @@ -1066,6 +1073,13 @@ ObjectNode partToVertex(JsonNode fromObject, ObjectNode parentObject) { + " Enterprise Agent Platform mode."); } + if (Common.getValueByPath(fromObject, new String[] {"audioTranscription"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"audioTranscription"}, + Common.getValueByPath(fromObject, new String[] {"audioTranscription"})); + } + return toObject; } diff --git a/src/main/java/com/google/genai/LiveConverters.java b/src/main/java/com/google/genai/LiveConverters.java index a3c6ee7776a..a20e60f8287 100644 --- a/src/main/java/com/google/genai/LiveConverters.java +++ b/src/main/java/com/google/genai/LiveConverters.java @@ -61,6 +61,20 @@ ObjectNode audioTranscriptionConfigToMldev(JsonNode fromObject, ObjectNode paren Common.getValueByPath(fromObject, new String[] {"adaptationPhrases"})); } + if (Common.getValueByPath(fromObject, new String[] {"wordTimestamp"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"wordTimestamp"}, + Common.getValueByPath(fromObject, new String[] {"wordTimestamp"})); + } + + if (Common.getValueByPath(fromObject, new String[] {"diarization"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"diarization"}, + Common.getValueByPath(fromObject, new String[] {"diarization"})); + } + return toObject; } @@ -518,6 +532,13 @@ ObjectNode generationConfigToVertex(JsonNode fromObject, ObjectNode parentObject + " Gemini Enterprise Agent Platform mode."); } + if (Common.getValueByPath(fromObject, new String[] {"audioTranscriptionConfig"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"audioTranscriptionConfig"}, + Common.getValueByPath(fromObject, new String[] {"audioTranscriptionConfig"})); + } + return toObject; } @@ -1907,6 +1928,13 @@ ObjectNode partToMldev(JsonNode fromObject, ObjectNode parentObject) { Common.getValueByPath(fromObject, new String[] {"partMetadata"})); } + if (Common.getValueByPath(fromObject, new String[] {"audioTranscription"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"audioTranscription"}, + Common.getValueByPath(fromObject, new String[] {"audioTranscription"})); + } + return toObject; } @@ -2014,6 +2042,13 @@ ObjectNode partToVertex(JsonNode fromObject, ObjectNode parentObject) { + " Enterprise Agent Platform mode."); } + if (Common.getValueByPath(fromObject, new String[] {"audioTranscription"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"audioTranscription"}, + Common.getValueByPath(fromObject, new String[] {"audioTranscription"})); + } + return toObject; } diff --git a/src/main/java/com/google/genai/Models.java b/src/main/java/com/google/genai/Models.java index 5540fd8b7dd..f520bb26ea0 100644 --- a/src/main/java/com/google/genai/Models.java +++ b/src/main/java/com/google/genai/Models.java @@ -144,6 +144,54 @@ void videoGenerationReferenceTypeMldevEnumValidate(Object enumValue) { } } + @ExcludeFromGeneratedCoverageReport + ObjectNode audioTranscriptionConfigToMldev( + JsonNode fromObject, ObjectNode parentObject, JsonNode rootObject) { + ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode(); + if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"languageCodes"}))) { + throw new IllegalArgumentException( + "languageCodes parameter is only supported in Gemini Enterprise Agent Platform mode, not" + + " in Gemini Developer API mode."); + } + + if (Common.getValueByPath(fromObject, new String[] {"languageAuto"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"languageAuto"}, + Common.getValueByPath(fromObject, new String[] {"languageAuto"})); + } + + if (Common.getValueByPath(fromObject, new String[] {"languageHints"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"languageHints"}, + Common.getValueByPath(fromObject, new String[] {"languageHints"})); + } + + if (Common.getValueByPath(fromObject, new String[] {"adaptationPhrases"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"adaptationPhrases"}, + Common.getValueByPath(fromObject, new String[] {"adaptationPhrases"})); + } + + if (Common.getValueByPath(fromObject, new String[] {"wordTimestamp"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"wordTimestamp"}, + Common.getValueByPath(fromObject, new String[] {"wordTimestamp"})); + } + + if (Common.getValueByPath(fromObject, new String[] {"diarization"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"diarization"}, + Common.getValueByPath(fromObject, new String[] {"diarization"})); + } + + return toObject; + } + @ExcludeFromGeneratedCoverageReport ObjectNode authConfigToMldev(JsonNode fromObject, ObjectNode parentObject, JsonNode rootObject) { ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode(); @@ -1746,6 +1794,17 @@ ObjectNode generateContentConfigToMldev( Common.getValueByPath(fromObject, new String[] {"serviceTier"})); } + if (Common.getValueByPath(fromObject, new String[] {"audioTranscriptionConfig"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"audioTranscriptionConfig"}, + audioTranscriptionConfigToMldev( + JsonSerializable.toJsonNode( + Common.getValueByPath(fromObject, new String[] {"audioTranscriptionConfig"})), + toObject, + rootObject)); + } + return toObject; } @@ -1998,6 +2057,13 @@ ObjectNode generateContentConfigToVertex( Common.getValueByPath(fromObject, new String[] {"serviceTier"})); } + if (Common.getValueByPath(fromObject, new String[] {"audioTranscriptionConfig"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"audioTranscriptionConfig"}, + Common.getValueByPath(fromObject, new String[] {"audioTranscriptionConfig"})); + } + return toObject; } @@ -3568,6 +3634,13 @@ ObjectNode generationConfigToVertex( + " Gemini Enterprise Agent Platform mode."); } + if (Common.getValueByPath(fromObject, new String[] {"audioTranscriptionConfig"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"audioTranscriptionConfig"}, + Common.getValueByPath(fromObject, new String[] {"audioTranscriptionConfig"})); + } + return toObject; } @@ -4401,6 +4474,13 @@ ObjectNode partToMldev(JsonNode fromObject, ObjectNode parentObject, JsonNode ro Common.getValueByPath(fromObject, new String[] {"partMetadata"})); } + if (Common.getValueByPath(fromObject, new String[] {"audioTranscription"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"audioTranscription"}, + Common.getValueByPath(fromObject, new String[] {"audioTranscription"})); + } + return toObject; } @@ -4510,6 +4590,13 @@ ObjectNode partToVertex(JsonNode fromObject, ObjectNode parentObject, JsonNode r + " Enterprise Agent Platform mode."); } + if (Common.getValueByPath(fromObject, new String[] {"audioTranscription"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"audioTranscription"}, + Common.getValueByPath(fromObject, new String[] {"audioTranscription"})); + } + return toObject; } diff --git a/src/main/java/com/google/genai/TokensConverters.java b/src/main/java/com/google/genai/TokensConverters.java index 54fb3cc9254..afa5aa387d4 100644 --- a/src/main/java/com/google/genai/TokensConverters.java +++ b/src/main/java/com/google/genai/TokensConverters.java @@ -61,6 +61,20 @@ ObjectNode audioTranscriptionConfigToMldev(JsonNode fromObject, ObjectNode paren Common.getValueByPath(fromObject, new String[] {"adaptationPhrases"})); } + if (Common.getValueByPath(fromObject, new String[] {"wordTimestamp"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"wordTimestamp"}, + Common.getValueByPath(fromObject, new String[] {"wordTimestamp"})); + } + + if (Common.getValueByPath(fromObject, new String[] {"diarization"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"diarization"}, + Common.getValueByPath(fromObject, new String[] {"diarization"})); + } + return toObject; } @@ -679,6 +693,13 @@ ObjectNode partToMldev(JsonNode fromObject, ObjectNode parentObject) { Common.getValueByPath(fromObject, new String[] {"partMetadata"})); } + if (Common.getValueByPath(fromObject, new String[] {"audioTranscription"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"audioTranscription"}, + Common.getValueByPath(fromObject, new String[] {"audioTranscription"})); + } + return toObject; } diff --git a/src/main/java/com/google/genai/Tunings.java b/src/main/java/com/google/genai/Tunings.java index b54595a3470..2de93d0d9cc 100644 --- a/src/main/java/com/google/genai/Tunings.java +++ b/src/main/java/com/google/genai/Tunings.java @@ -1226,6 +1226,13 @@ ObjectNode generationConfigFromVertex( Common.getValueByPath(fromObject, new String[] {"responseFormat"})); } + if (Common.getValueByPath(fromObject, new String[] {"audioTranscriptionConfig"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"audioTranscriptionConfig"}, + Common.getValueByPath(fromObject, new String[] {"audioTranscriptionConfig"})); + } + return toObject; } @@ -1411,6 +1418,13 @@ ObjectNode generationConfigToVertex( + " Gemini Enterprise Agent Platform mode."); } + if (Common.getValueByPath(fromObject, new String[] {"audioTranscriptionConfig"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"audioTranscriptionConfig"}, + Common.getValueByPath(fromObject, new String[] {"audioTranscriptionConfig"})); + } + return toObject; } diff --git a/src/main/java/com/google/genai/types/AudioTranscriptionConfig.java b/src/main/java/com/google/genai/types/AudioTranscriptionConfig.java index ae12e6af68c..ce82903eff0 100644 --- a/src/main/java/com/google/genai/types/AudioTranscriptionConfig.java +++ b/src/main/java/com/google/genai/types/AudioTranscriptionConfig.java @@ -51,6 +51,14 @@ public abstract class AudioTranscriptionConfig extends JsonSerializable { @JsonProperty("adaptationPhrases") public abstract Optional> adaptationPhrases(); + /** Configures word-level timestamp generation. */ + @JsonProperty("wordTimestamp") + public abstract Optional wordTimestamp(); + + /** Configures speaker diarization. */ + @JsonProperty("diarization") + public abstract Optional diarization(); + /** Instantiates a builder for AudioTranscriptionConfig. */ @ExcludeFromGeneratedCoverageReport public static Builder builder() { @@ -187,6 +195,42 @@ public Builder clearAdaptationPhrases() { return adaptationPhrases(Optional.empty()); } + /** + * Setter for wordTimestamp. + * + *

wordTimestamp: Configures word-level timestamp generation. + */ + @JsonProperty("wordTimestamp") + public abstract Builder wordTimestamp(boolean wordTimestamp); + + @ExcludeFromGeneratedCoverageReport + abstract Builder wordTimestamp(Optional wordTimestamp); + + /** Clears the value of wordTimestamp field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearWordTimestamp() { + return wordTimestamp(Optional.empty()); + } + + /** + * Setter for diarization. + * + *

diarization: Configures speaker diarization. + */ + @JsonProperty("diarization") + public abstract Builder diarization(boolean diarization); + + @ExcludeFromGeneratedCoverageReport + abstract Builder diarization(Optional diarization); + + /** Clears the value of diarization field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearDiarization() { + return diarization(Optional.empty()); + } + public abstract AudioTranscriptionConfig build(); } diff --git a/src/main/java/com/google/genai/types/GenerateContentConfig.java b/src/main/java/com/google/genai/types/GenerateContentConfig.java index 1ef4635f37d..4b502df98cc 100644 --- a/src/main/java/com/google/genai/types/GenerateContentConfig.java +++ b/src/main/java/com/google/genai/types/GenerateContentConfig.java @@ -243,6 +243,10 @@ public abstract class GenerateContentConfig extends JsonSerializable { @JsonProperty("serviceTier") public abstract Optional serviceTier(); + /** Optional. Configuration for audio transcription (speech recognition). */ + @JsonProperty("audioTranscriptionConfig") + public abstract Optional audioTranscriptionConfig(); + /** Instantiates a builder for GenerateContentConfig. */ @ExcludeFromGeneratedCoverageReport public static Builder builder() { @@ -1145,6 +1149,39 @@ public Builder serviceTier(String serviceTier) { return serviceTier(new ServiceTier(serviceTier)); } + /** + * Setter for audioTranscriptionConfig. + * + *

audioTranscriptionConfig: Optional. Configuration for audio transcription (speech + * recognition). + */ + @JsonProperty("audioTranscriptionConfig") + public abstract Builder audioTranscriptionConfig( + AudioTranscriptionConfig audioTranscriptionConfig); + + /** + * Setter for audioTranscriptionConfig builder. + * + *

audioTranscriptionConfig: Optional. Configuration for audio transcription (speech + * recognition). + */ + @CanIgnoreReturnValue + public Builder audioTranscriptionConfig( + AudioTranscriptionConfig.Builder audioTranscriptionConfigBuilder) { + return audioTranscriptionConfig(audioTranscriptionConfigBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder audioTranscriptionConfig( + Optional audioTranscriptionConfig); + + /** Clears the value of audioTranscriptionConfig field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearAudioTranscriptionConfig() { + return audioTranscriptionConfig(Optional.empty()); + } + public abstract GenerateContentConfig build(); } diff --git a/src/main/java/com/google/genai/types/GenerationConfig.java b/src/main/java/com/google/genai/types/GenerationConfig.java index e35403c01a4..8cc5d6b642b 100644 --- a/src/main/java/com/google/genai/types/GenerationConfig.java +++ b/src/main/java/com/google/genai/types/GenerationConfig.java @@ -227,6 +227,10 @@ public abstract class GenerationConfig extends JsonSerializable { @JsonProperty("translationConfig") public abstract Optional translationConfig(); + /** Optional. Configuration for audio transcription (speech recognition). */ + @JsonProperty("audioTranscriptionConfig") + public abstract Optional audioTranscriptionConfig(); + /** Instantiates a builder for GenerationConfig. */ @ExcludeFromGeneratedCoverageReport public static Builder builder() { @@ -948,6 +952,39 @@ public Builder clearTranslationConfig() { return translationConfig(Optional.empty()); } + /** + * Setter for audioTranscriptionConfig. + * + *

audioTranscriptionConfig: Optional. Configuration for audio transcription (speech + * recognition). + */ + @JsonProperty("audioTranscriptionConfig") + public abstract Builder audioTranscriptionConfig( + AudioTranscriptionConfig audioTranscriptionConfig); + + /** + * Setter for audioTranscriptionConfig builder. + * + *

audioTranscriptionConfig: Optional. Configuration for audio transcription (speech + * recognition). + */ + @CanIgnoreReturnValue + public Builder audioTranscriptionConfig( + AudioTranscriptionConfig.Builder audioTranscriptionConfigBuilder) { + return audioTranscriptionConfig(audioTranscriptionConfigBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder audioTranscriptionConfig( + Optional audioTranscriptionConfig); + + /** Clears the value of audioTranscriptionConfig field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearAudioTranscriptionConfig() { + return audioTranscriptionConfig(Optional.empty()); + } + public abstract GenerationConfig build(); } diff --git a/src/main/java/com/google/genai/types/Part.java b/src/main/java/com/google/genai/types/Part.java index f8f75c3c17a..f9f3b41b6f8 100644 --- a/src/main/java/com/google/genai/types/Part.java +++ b/src/main/java/com/google/genai/types/Part.java @@ -122,6 +122,10 @@ public abstract class Part extends JsonSerializable { @JsonProperty("partMetadata") public abstract Optional> partMetadata(); + /** Output only. The transcription of the audio part. */ + @JsonProperty("audioTranscription") + public abstract Optional audioTranscription(); + /** Instantiates a builder for Part. */ @ExcludeFromGeneratedCoverageReport public static Builder builder() { @@ -515,6 +519,34 @@ public Builder clearPartMetadata() { return partMetadata(Optional.empty()); } + /** + * Setter for audioTranscription. + * + *

audioTranscription: Output only. The transcription of the audio part. + */ + @JsonProperty("audioTranscription") + public abstract Builder audioTranscription(Transcription audioTranscription); + + /** + * Setter for audioTranscription builder. + * + *

audioTranscription: Output only. The transcription of the audio part. + */ + @CanIgnoreReturnValue + public Builder audioTranscription(Transcription.Builder audioTranscriptionBuilder) { + return audioTranscription(audioTranscriptionBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder audioTranscription(Optional audioTranscription); + + /** Clears the value of audioTranscription field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearAudioTranscription() { + return audioTranscription(Optional.empty()); + } + public abstract Part build(); } diff --git a/src/main/java/com/google/genai/types/Transcription.java b/src/main/java/com/google/genai/types/Transcription.java index 9d276000015..48be456279f 100644 --- a/src/main/java/com/google/genai/types/Transcription.java +++ b/src/main/java/com/google/genai/types/Transcription.java @@ -18,12 +18,16 @@ package com.google.genai.types; +import static com.google.common.collect.ImmutableList.toImmutableList; + import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.google.auto.value.AutoValue; import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.genai.JsonSerializable; +import java.util.Arrays; +import java.util.List; import java.util.Optional; /** Audio transcription in Server Content. */ @@ -42,6 +46,14 @@ public abstract class Transcription extends JsonSerializable { @JsonProperty("languageCode") public abstract Optional languageCode(); + /** A label identifying the speaker of this audio segment (e.g. "spk_1", "spk_2"). */ + @JsonProperty("speakerLabel") + public abstract Optional speakerLabel(); + + /** Detailed word-level transcriptions and timing details. */ + @JsonProperty("words") + public abstract Optional> words(); + /** Instantiates a builder for Transcription. */ @ExcludeFromGeneratedCoverageReport public static Builder builder() { @@ -114,6 +126,66 @@ public Builder clearLanguageCode() { return languageCode(Optional.empty()); } + /** + * Setter for speakerLabel. + * + *

speakerLabel: A label identifying the speaker of this audio segment (e.g. "spk_1", + * "spk_2"). + */ + @JsonProperty("speakerLabel") + public abstract Builder speakerLabel(String speakerLabel); + + @ExcludeFromGeneratedCoverageReport + abstract Builder speakerLabel(Optional speakerLabel); + + /** Clears the value of speakerLabel field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearSpeakerLabel() { + return speakerLabel(Optional.empty()); + } + + /** + * Setter for words. + * + *

words: Detailed word-level transcriptions and timing details. + */ + @JsonProperty("words") + public abstract Builder words(List words); + + /** + * Setter for words. + * + *

words: Detailed word-level transcriptions and timing details. + */ + @CanIgnoreReturnValue + public Builder words(WordInfo... words) { + return words(Arrays.asList(words)); + } + + /** + * Setter for words builder. + * + *

words: Detailed word-level transcriptions and timing details. + */ + @CanIgnoreReturnValue + public Builder words(WordInfo.Builder... wordsBuilders) { + return words( + Arrays.asList(wordsBuilders).stream() + .map(WordInfo.Builder::build) + .collect(toImmutableList())); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder words(Optional> words); + + /** Clears the value of words field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearWords() { + return words(Optional.empty()); + } + public abstract Transcription build(); } diff --git a/src/main/java/com/google/genai/types/WordInfo.java b/src/main/java/com/google/genai/types/WordInfo.java new file mode 100644 index 00000000000..b3916c96767 --- /dev/null +++ b/src/main/java/com/google/genai/types/WordInfo.java @@ -0,0 +1,125 @@ +/* + * Copyright 2025 Google LLC + * + * 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 + * + * https://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. + */ + +// Auto-generated code. Do not edit. + +package com.google.genai.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.auto.value.AutoValue; +import com.google.errorprone.annotations.CanIgnoreReturnValue; +import com.google.genai.JsonSerializable; +import java.util.Optional; + +/** Information about a single recognized word. */ +@AutoValue +@JsonDeserialize(builder = WordInfo.Builder.class) +public abstract class WordInfo extends JsonSerializable { + /** Transcript of the word. */ + @JsonProperty("word") + public abstract Optional word(); + + /** Start offset in time of the word relative to the start of the audio. */ + @JsonProperty("startOffset") + public abstract Optional startOffset(); + + /** End offset in time of the word relative to the start of the audio. */ + @JsonProperty("endOffset") + public abstract Optional endOffset(); + + /** Instantiates a builder for WordInfo. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_WordInfo.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for WordInfo. */ + @AutoValue.Builder + public abstract static class Builder { + /** For internal usage. Please use `WordInfo.builder()` for instantiation. */ + @JsonCreator + private static Builder create() { + return new AutoValue_WordInfo.Builder(); + } + + /** + * Setter for word. + * + *

word: Transcript of the word. + */ + @JsonProperty("word") + public abstract Builder word(String word); + + @ExcludeFromGeneratedCoverageReport + abstract Builder word(Optional word); + + /** Clears the value of word field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearWord() { + return word(Optional.empty()); + } + + /** + * Setter for startOffset. + * + *

startOffset: Start offset in time of the word relative to the start of the audio. + */ + @JsonProperty("startOffset") + public abstract Builder startOffset(String startOffset); + + @ExcludeFromGeneratedCoverageReport + abstract Builder startOffset(Optional startOffset); + + /** Clears the value of startOffset field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearStartOffset() { + return startOffset(Optional.empty()); + } + + /** + * Setter for endOffset. + * + *

endOffset: End offset in time of the word relative to the start of the audio. + */ + @JsonProperty("endOffset") + public abstract Builder endOffset(String endOffset); + + @ExcludeFromGeneratedCoverageReport + abstract Builder endOffset(Optional endOffset); + + /** Clears the value of endOffset field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearEndOffset() { + return endOffset(Optional.empty()); + } + + public abstract WordInfo build(); + } + + /** Deserializes a JSON string to a WordInfo object. */ + @ExcludeFromGeneratedCoverageReport + public static WordInfo fromJson(String jsonString) { + return JsonSerializable.fromJsonString(jsonString, WordInfo.class); + } +}