diff --git a/src/main/java/com/google/genai/LiveConverters.java b/src/main/java/com/google/genai/LiveConverters.java index 301b6a15965..61b563bb24b 100644 --- a/src/main/java/com/google/genai/LiveConverters.java +++ b/src/main/java/com/google/genai/LiveConverters.java @@ -728,6 +728,11 @@ ObjectNode liveClientSetupToMldev(JsonNode fromObject, ObjectNode parentObject) Common.getValueByPath(fromObject, new String[] {"proactivity"})); } + if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"explicitVadSignal"}))) { + throw new IllegalArgumentException( + "explicitVadSignal parameter is not supported in Gemini API."); + } + return toObject; } @@ -814,6 +819,13 @@ ObjectNode liveClientSetupToVertex(JsonNode fromObject, ObjectNode parentObject) Common.getValueByPath(fromObject, new String[] {"proactivity"})); } + if (Common.getValueByPath(fromObject, new String[] {"explicitVadSignal"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"explicitVadSignal"}, + Common.getValueByPath(fromObject, new String[] {"explicitVadSignal"})); + } + return toObject; } @@ -961,6 +973,11 @@ ObjectNode liveConnectConfigToMldev(JsonNode fromObject, ObjectNode parentObject Common.getValueByPath(fromObject, new String[] {"proactivity"})); } + if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"explicitVadSignal"}))) { + throw new IllegalArgumentException( + "explicitVadSignal parameter is not supported in Gemini API."); + } + return toObject; } @@ -1105,6 +1122,13 @@ ObjectNode liveConnectConfigToVertex(JsonNode fromObject, ObjectNode parentObjec Common.getValueByPath(fromObject, new String[] {"proactivity"})); } + if (Common.getValueByPath(fromObject, new String[] {"explicitVadSignal"}) != null) { + Common.setValueByPath( + parentObject, + new String[] {"setup", "explicitVadSignal"}, + Common.getValueByPath(fromObject, new String[] {"explicitVadSignal"})); + } + return toObject; } @@ -1337,6 +1361,13 @@ ObjectNode liveServerMessageFromVertex(JsonNode fromObject, ObjectNode parentObj Common.getValueByPath(fromObject, new String[] {"sessionResumptionUpdate"})); } + if (Common.getValueByPath(fromObject, new String[] {"voiceActivityDetectionSignal"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"voiceActivityDetectionSignal"}, + Common.getValueByPath(fromObject, new String[] {"voiceActivityDetectionSignal"})); + } + return toObject; } diff --git a/src/main/java/com/google/genai/TokensConverters.java b/src/main/java/com/google/genai/TokensConverters.java index f18a52eed3c..b1e3cbbd00f 100644 --- a/src/main/java/com/google/genai/TokensConverters.java +++ b/src/main/java/com/google/genai/TokensConverters.java @@ -395,6 +395,11 @@ ObjectNode liveConnectConfigToMldev(JsonNode fromObject, ObjectNode parentObject Common.getValueByPath(fromObject, new String[] {"proactivity"})); } + if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"explicitVadSignal"}))) { + throw new IllegalArgumentException( + "explicitVadSignal parameter is not supported in Gemini API."); + } + return toObject; } diff --git a/src/main/java/com/google/genai/types/LiveClientSetup.java b/src/main/java/com/google/genai/types/LiveClientSetup.java index f9cdb8e322e..91618c662e9 100644 --- a/src/main/java/com/google/genai/types/LiveClientSetup.java +++ b/src/main/java/com/google/genai/types/LiveClientSetup.java @@ -95,6 +95,13 @@ public abstract class LiveClientSetup extends JsonSerializable { @JsonProperty("proactivity") public abstract Optional proactivity(); + /** + * Configures the explicit VAD signal. If enabled, the client will send vad_signal to indicate the + * start and end of speech. This allows the server to process the audio more efficiently. + */ + @JsonProperty("explicitVadSignal") + public abstract Optional explicitVadSignal(); + /** Instantiates a builder for LiveClientSetup. */ @ExcludeFromGeneratedCoverageReport public static Builder builder() { @@ -432,6 +439,26 @@ public Builder clearProactivity() { return proactivity(Optional.empty()); } + /** + * Setter for explicitVadSignal. + * + *

explicitVadSignal: Configures the explicit VAD signal. If enabled, the client will send + * vad_signal to indicate the start and end of speech. This allows the server to process the + * audio more efficiently. + */ + @JsonProperty("explicitVadSignal") + public abstract Builder explicitVadSignal(boolean explicitVadSignal); + + @ExcludeFromGeneratedCoverageReport + abstract Builder explicitVadSignal(Optional explicitVadSignal); + + /** Clears the value of explicitVadSignal field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearExplicitVadSignal() { + return explicitVadSignal(Optional.empty()); + } + public abstract LiveClientSetup build(); } diff --git a/src/main/java/com/google/genai/types/LiveConnectConfig.java b/src/main/java/com/google/genai/types/LiveConnectConfig.java index 91adc1d44a4..ba64495076d 100644 --- a/src/main/java/com/google/genai/types/LiveConnectConfig.java +++ b/src/main/java/com/google/genai/types/LiveConnectConfig.java @@ -154,6 +154,13 @@ public abstract class LiveConnectConfig extends JsonSerializable { @JsonProperty("proactivity") public abstract Optional proactivity(); + /** + * Configures the explicit VAD signal. If enabled, the client will send vad_signal to indicate the + * start and end of speech. This allows the server to process the audio more efficiently. + */ + @JsonProperty("explicitVadSignal") + public abstract Optional explicitVadSignal(); + /** Instantiates a builder for LiveConnectConfig. */ @ExcludeFromGeneratedCoverageReport public static Builder builder() { @@ -762,6 +769,26 @@ public Builder clearProactivity() { return proactivity(Optional.empty()); } + /** + * Setter for explicitVadSignal. + * + *

explicitVadSignal: Configures the explicit VAD signal. If enabled, the client will send + * vad_signal to indicate the start and end of speech. This allows the server to process the + * audio more efficiently. + */ + @JsonProperty("explicitVadSignal") + public abstract Builder explicitVadSignal(boolean explicitVadSignal); + + @ExcludeFromGeneratedCoverageReport + abstract Builder explicitVadSignal(Optional explicitVadSignal); + + /** Clears the value of explicitVadSignal field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearExplicitVadSignal() { + return explicitVadSignal(Optional.empty()); + } + public abstract LiveConnectConfig build(); } diff --git a/src/main/java/com/google/genai/types/LiveServerMessage.java b/src/main/java/com/google/genai/types/LiveServerMessage.java index 2cff96bc0dc..b7e6ed37deb 100644 --- a/src/main/java/com/google/genai/types/LiveServerMessage.java +++ b/src/main/java/com/google/genai/types/LiveServerMessage.java @@ -64,6 +64,10 @@ public abstract class LiveServerMessage extends JsonSerializable { @JsonProperty("sessionResumptionUpdate") public abstract Optional sessionResumptionUpdate(); + /** Voice activity detection signal. */ + @JsonProperty("voiceActivityDetectionSignal") + public abstract Optional voiceActivityDetectionSignal(); + /** Instantiates a builder for LiveServerMessage. */ @ExcludeFromGeneratedCoverageReport public static Builder builder() { @@ -290,6 +294,37 @@ public Builder clearSessionResumptionUpdate() { return sessionResumptionUpdate(Optional.empty()); } + /** + * Setter for voiceActivityDetectionSignal. + * + *

voiceActivityDetectionSignal: Voice activity detection signal. + */ + @JsonProperty("voiceActivityDetectionSignal") + public abstract Builder voiceActivityDetectionSignal( + VoiceActivityDetectionSignal voiceActivityDetectionSignal); + + /** + * Setter for voiceActivityDetectionSignal builder. + * + *

voiceActivityDetectionSignal: Voice activity detection signal. + */ + @CanIgnoreReturnValue + public Builder voiceActivityDetectionSignal( + VoiceActivityDetectionSignal.Builder voiceActivityDetectionSignalBuilder) { + return voiceActivityDetectionSignal(voiceActivityDetectionSignalBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder voiceActivityDetectionSignal( + Optional voiceActivityDetectionSignal); + + /** Clears the value of voiceActivityDetectionSignal field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearVoiceActivityDetectionSignal() { + return voiceActivityDetectionSignal(Optional.empty()); + } + public abstract LiveServerMessage build(); } diff --git a/src/main/java/com/google/genai/types/VadSignalType.java b/src/main/java/com/google/genai/types/VadSignalType.java new file mode 100644 index 00000000000..6c642bb6ead --- /dev/null +++ b/src/main/java/com/google/genai/types/VadSignalType.java @@ -0,0 +1,111 @@ +/* + * 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.JsonValue; +import com.google.common.base.Ascii; +import java.util.Objects; + +/** The type of the VAD signal. */ +public class VadSignalType { + + /** Enum representing the known values for VadSignalType. */ + public enum Known { + /** The default is VAD_SIGNAL_TYPE_UNSPECIFIED. */ + VAD_SIGNAL_TYPE_UNSPECIFIED, + + /** Start of sentence signal. */ + VAD_SIGNAL_TYPE_SOS, + + /** End of sentence signal. */ + VAD_SIGNAL_TYPE_EOS + } + + private Known vadSignalTypeEnum; + private final String value; + + @JsonCreator + public VadSignalType(String value) { + this.value = value; + for (Known vadSignalTypeEnum : Known.values()) { + if (Ascii.equalsIgnoreCase(vadSignalTypeEnum.toString(), value)) { + this.vadSignalTypeEnum = vadSignalTypeEnum; + break; + } + } + if (this.vadSignalTypeEnum == null) { + this.vadSignalTypeEnum = Known.VAD_SIGNAL_TYPE_UNSPECIFIED; + } + } + + public VadSignalType(Known knownValue) { + this.vadSignalTypeEnum = knownValue; + this.value = knownValue.toString(); + } + + @ExcludeFromGeneratedCoverageReport + @Override + @JsonValue + public String toString() { + return this.value; + } + + @ExcludeFromGeneratedCoverageReport + @SuppressWarnings("PatternMatchingInstanceof") + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null) { + return false; + } + + if (!(o instanceof VadSignalType)) { + return false; + } + + VadSignalType other = (VadSignalType) o; + + if (this.vadSignalTypeEnum != Known.VAD_SIGNAL_TYPE_UNSPECIFIED + && other.vadSignalTypeEnum != Known.VAD_SIGNAL_TYPE_UNSPECIFIED) { + return this.vadSignalTypeEnum == other.vadSignalTypeEnum; + } else if (this.vadSignalTypeEnum == Known.VAD_SIGNAL_TYPE_UNSPECIFIED + && other.vadSignalTypeEnum == Known.VAD_SIGNAL_TYPE_UNSPECIFIED) { + return this.value.equals(other.value); + } + return false; + } + + @ExcludeFromGeneratedCoverageReport + @Override + public int hashCode() { + if (this.vadSignalTypeEnum != Known.VAD_SIGNAL_TYPE_UNSPECIFIED) { + return this.vadSignalTypeEnum.hashCode(); + } else { + return Objects.hashCode(this.value); + } + } + + @ExcludeFromGeneratedCoverageReport + public Known knownEnum() { + return this.vadSignalTypeEnum; + } +} diff --git a/src/main/java/com/google/genai/types/VoiceActivityDetectionSignal.java b/src/main/java/com/google/genai/types/VoiceActivityDetectionSignal.java new file mode 100644 index 00000000000..7e095317e8c --- /dev/null +++ b/src/main/java/com/google/genai/types/VoiceActivityDetectionSignal.java @@ -0,0 +1,103 @@ +/* + * 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; + +/** None */ +@AutoValue +@JsonDeserialize(builder = VoiceActivityDetectionSignal.Builder.class) +public abstract class VoiceActivityDetectionSignal extends JsonSerializable { + /** The type of the VAD signal. */ + @JsonProperty("vadSignalType") + public abstract Optional vadSignalType(); + + /** Instantiates a builder for VoiceActivityDetectionSignal. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_VoiceActivityDetectionSignal.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for VoiceActivityDetectionSignal. */ + @AutoValue.Builder + public abstract static class Builder { + /** + * For internal usage. Please use `VoiceActivityDetectionSignal.builder()` for instantiation. + */ + @JsonCreator + private static Builder create() { + return new AutoValue_VoiceActivityDetectionSignal.Builder(); + } + + /** + * Setter for vadSignalType. + * + *

vadSignalType: The type of the VAD signal. + */ + @JsonProperty("vadSignalType") + public abstract Builder vadSignalType(VadSignalType vadSignalType); + + @ExcludeFromGeneratedCoverageReport + abstract Builder vadSignalType(Optional vadSignalType); + + /** Clears the value of vadSignalType field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearVadSignalType() { + return vadSignalType(Optional.empty()); + } + + /** + * Setter for vadSignalType given a known enum. + * + *

vadSignalType: The type of the VAD signal. + */ + @CanIgnoreReturnValue + public Builder vadSignalType(VadSignalType.Known knownType) { + return vadSignalType(new VadSignalType(knownType)); + } + + /** + * Setter for vadSignalType given a string. + * + *

vadSignalType: The type of the VAD signal. + */ + @CanIgnoreReturnValue + public Builder vadSignalType(String vadSignalType) { + return vadSignalType(new VadSignalType(vadSignalType)); + } + + public abstract VoiceActivityDetectionSignal build(); + } + + /** Deserializes a JSON string to a VoiceActivityDetectionSignal object. */ + @ExcludeFromGeneratedCoverageReport + public static VoiceActivityDetectionSignal fromJson(String jsonString) { + return JsonSerializable.fromJsonString(jsonString, VoiceActivityDetectionSignal.class); + } +}