Skip to content

Commit dbe314d

Browse files
MarkDaoustcopybara-github
authored andcommitted
chore: Tests for ReplicatedVoiceConfig
PiperOrigin-RevId: 841593648
1 parent 36ba543 commit dbe314d

File tree

5 files changed

+174
-38
lines changed

5 files changed

+174
-38
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,18 +1452,18 @@ ObjectNode sessionResumptionConfigToMldev(JsonNode fromObject, ObjectNode parent
14521452
@ExcludeFromGeneratedCoverageReport
14531453
ObjectNode speechConfigToVertex(JsonNode fromObject, ObjectNode parentObject) {
14541454
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
1455-
if (Common.getValueByPath(fromObject, new String[] {"languageCode"}) != null) {
1455+
if (Common.getValueByPath(fromObject, new String[] {"voiceConfig"}) != null) {
14561456
Common.setValueByPath(
14571457
toObject,
1458-
new String[] {"languageCode"},
1459-
Common.getValueByPath(fromObject, new String[] {"languageCode"}));
1458+
new String[] {"voiceConfig"},
1459+
Common.getValueByPath(fromObject, new String[] {"voiceConfig"}));
14601460
}
14611461

1462-
if (Common.getValueByPath(fromObject, new String[] {"voiceConfig"}) != null) {
1462+
if (Common.getValueByPath(fromObject, new String[] {"languageCode"}) != null) {
14631463
Common.setValueByPath(
14641464
toObject,
1465-
new String[] {"voiceConfig"},
1466-
Common.getValueByPath(fromObject, new String[] {"voiceConfig"}));
1465+
new String[] {"languageCode"},
1466+
Common.getValueByPath(fromObject, new String[] {"languageCode"}));
14671467
}
14681468

14691469
if (!Common.isZero(

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4198,18 +4198,18 @@ ObjectNode segmentImageSourceToVertex(JsonNode fromObject, ObjectNode parentObje
41984198
@ExcludeFromGeneratedCoverageReport
41994199
ObjectNode speechConfigToVertex(JsonNode fromObject, ObjectNode parentObject) {
42004200
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
4201-
if (Common.getValueByPath(fromObject, new String[] {"languageCode"}) != null) {
4201+
if (Common.getValueByPath(fromObject, new String[] {"voiceConfig"}) != null) {
42024202
Common.setValueByPath(
42034203
toObject,
4204-
new String[] {"languageCode"},
4205-
Common.getValueByPath(fromObject, new String[] {"languageCode"}));
4204+
new String[] {"voiceConfig"},
4205+
Common.getValueByPath(fromObject, new String[] {"voiceConfig"}));
42064206
}
42074207

4208-
if (Common.getValueByPath(fromObject, new String[] {"voiceConfig"}) != null) {
4208+
if (Common.getValueByPath(fromObject, new String[] {"languageCode"}) != null) {
42094209
Common.setValueByPath(
42104210
toObject,
4211-
new String[] {"voiceConfig"},
4212-
Common.getValueByPath(fromObject, new String[] {"voiceConfig"}));
4211+
new String[] {"languageCode"},
4212+
Common.getValueByPath(fromObject, new String[] {"languageCode"}));
42134213
}
42144214

42154215
if (!Common.isZero(
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/*
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
// Auto-generated code. Do not edit.
18+
19+
package com.google.genai.types;
20+
21+
import com.fasterxml.jackson.annotation.JsonCreator;
22+
import com.fasterxml.jackson.annotation.JsonProperty;
23+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
24+
import com.google.auto.value.AutoValue;
25+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
26+
import com.google.genai.JsonSerializable;
27+
import java.util.Optional;
28+
29+
/** ReplicatedVoiceConfig is used to configure replicated voice. */
30+
@AutoValue
31+
@JsonDeserialize(builder = ReplicatedVoiceConfig.Builder.class)
32+
public abstract class ReplicatedVoiceConfig extends JsonSerializable {
33+
/** The mime type of the replicated voice. */
34+
@JsonProperty("mimeType")
35+
public abstract Optional<String> mimeType();
36+
37+
/** The sample audio of the replicated voice. */
38+
@JsonProperty("voiceSampleAudio")
39+
public abstract Optional<byte[]> voiceSampleAudio();
40+
41+
/** Instantiates a builder for ReplicatedVoiceConfig. */
42+
@ExcludeFromGeneratedCoverageReport
43+
public static Builder builder() {
44+
return new AutoValue_ReplicatedVoiceConfig.Builder();
45+
}
46+
47+
/** Creates a builder with the same values as this instance. */
48+
public abstract Builder toBuilder();
49+
50+
/** Builder for ReplicatedVoiceConfig. */
51+
@AutoValue.Builder
52+
public abstract static class Builder {
53+
/** For internal usage. Please use `ReplicatedVoiceConfig.builder()` for instantiation. */
54+
@JsonCreator
55+
private static Builder create() {
56+
return new AutoValue_ReplicatedVoiceConfig.Builder();
57+
}
58+
59+
/**
60+
* Setter for mimeType.
61+
*
62+
* <p>mimeType: The mime type of the replicated voice.
63+
*/
64+
@JsonProperty("mimeType")
65+
public abstract Builder mimeType(String mimeType);
66+
67+
@ExcludeFromGeneratedCoverageReport
68+
abstract Builder mimeType(Optional<String> mimeType);
69+
70+
/** Clears the value of mimeType field. */
71+
@ExcludeFromGeneratedCoverageReport
72+
@CanIgnoreReturnValue
73+
public Builder clearMimeType() {
74+
return mimeType(Optional.empty());
75+
}
76+
77+
/**
78+
* Setter for voiceSampleAudio.
79+
*
80+
* <p>voiceSampleAudio: The sample audio of the replicated voice.
81+
*/
82+
@JsonProperty("voiceSampleAudio")
83+
public abstract Builder voiceSampleAudio(byte[] voiceSampleAudio);
84+
85+
@ExcludeFromGeneratedCoverageReport
86+
abstract Builder voiceSampleAudio(Optional<byte[]> voiceSampleAudio);
87+
88+
/** Clears the value of voiceSampleAudio field. */
89+
@ExcludeFromGeneratedCoverageReport
90+
@CanIgnoreReturnValue
91+
public Builder clearVoiceSampleAudio() {
92+
return voiceSampleAudio(Optional.empty());
93+
}
94+
95+
public abstract ReplicatedVoiceConfig build();
96+
}
97+
98+
/** Deserializes a JSON string to a ReplicatedVoiceConfig object. */
99+
@ExcludeFromGeneratedCoverageReport
100+
public static ReplicatedVoiceConfig fromJson(String jsonString) {
101+
return JsonSerializable.fromJsonString(jsonString, ReplicatedVoiceConfig.class);
102+
}
103+
}

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

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@
2626
import com.google.genai.JsonSerializable;
2727
import java.util.Optional;
2828

29-
/** The speech generation config. */
29+
/** None */
3030
@AutoValue
3131
@JsonDeserialize(builder = SpeechConfig.Builder.class)
3232
public abstract class SpeechConfig extends JsonSerializable {
33+
/** Configuration for the voice of the response. */
34+
@JsonProperty("voiceConfig")
35+
public abstract Optional<VoiceConfig> voiceConfig();
36+
3337
/** Optional. Language code (ISO 639. e.g. en-US) for the speech synthesization. */
3438
@JsonProperty("languageCode")
3539
public abstract Optional<String> languageCode();
3640

37-
/** The configuration for the speaker to use. */
38-
@JsonProperty("voiceConfig")
39-
public abstract Optional<VoiceConfig> voiceConfig();
40-
4141
/**
4242
* Optional. The configuration for the multi-speaker setup. It is mutually exclusive with the
4343
* voice_config field. This field is not supported in Vertex AI.
@@ -63,36 +63,18 @@ private static Builder create() {
6363
return new AutoValue_SpeechConfig.Builder();
6464
}
6565

66-
/**
67-
* Setter for languageCode.
68-
*
69-
* <p>languageCode: Optional. Language code (ISO 639. e.g. en-US) for the speech synthesization.
70-
*/
71-
@JsonProperty("languageCode")
72-
public abstract Builder languageCode(String languageCode);
73-
74-
@ExcludeFromGeneratedCoverageReport
75-
abstract Builder languageCode(Optional<String> languageCode);
76-
77-
/** Clears the value of languageCode field. */
78-
@ExcludeFromGeneratedCoverageReport
79-
@CanIgnoreReturnValue
80-
public Builder clearLanguageCode() {
81-
return languageCode(Optional.empty());
82-
}
83-
8466
/**
8567
* Setter for voiceConfig.
8668
*
87-
* <p>voiceConfig: The configuration for the speaker to use.
69+
* <p>voiceConfig: Configuration for the voice of the response.
8870
*/
8971
@JsonProperty("voiceConfig")
9072
public abstract Builder voiceConfig(VoiceConfig voiceConfig);
9173

9274
/**
9375
* Setter for voiceConfig builder.
9476
*
95-
* <p>voiceConfig: The configuration for the speaker to use.
77+
* <p>voiceConfig: Configuration for the voice of the response.
9678
*/
9779
@CanIgnoreReturnValue
9880
public Builder voiceConfig(VoiceConfig.Builder voiceConfigBuilder) {
@@ -109,6 +91,24 @@ public Builder clearVoiceConfig() {
10991
return voiceConfig(Optional.empty());
11092
}
11193

94+
/**
95+
* Setter for languageCode.
96+
*
97+
* <p>languageCode: Optional. Language code (ISO 639. e.g. en-US) for the speech synthesization.
98+
*/
99+
@JsonProperty("languageCode")
100+
public abstract Builder languageCode(String languageCode);
101+
102+
@ExcludeFromGeneratedCoverageReport
103+
abstract Builder languageCode(Optional<String> languageCode);
104+
105+
/** Clears the value of languageCode field. */
106+
@ExcludeFromGeneratedCoverageReport
107+
@CanIgnoreReturnValue
108+
public Builder clearLanguageCode() {
109+
return languageCode(Optional.empty());
110+
}
111+
112112
/**
113113
* Setter for multiSpeakerVoiceConfig.
114114
*

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

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,14 @@
2626
import com.google.genai.JsonSerializable;
2727
import java.util.Optional;
2828

29-
/** The configuration for the voice to use. */
29+
/** None */
3030
@AutoValue
3131
@JsonDeserialize(builder = VoiceConfig.Builder.class)
3232
public abstract class VoiceConfig extends JsonSerializable {
33+
/** If true, the model will use a replicated voice for the response. */
34+
@JsonProperty("replicatedVoiceConfig")
35+
public abstract Optional<ReplicatedVoiceConfig> replicatedVoiceConfig();
36+
3337
/** The configuration for the prebuilt voice to use. */
3438
@JsonProperty("prebuiltVoiceConfig")
3539
public abstract Optional<PrebuiltVoiceConfig> prebuiltVoiceConfig();
@@ -52,6 +56,35 @@ private static Builder create() {
5256
return new AutoValue_VoiceConfig.Builder();
5357
}
5458

59+
/**
60+
* Setter for replicatedVoiceConfig.
61+
*
62+
* <p>replicatedVoiceConfig: If true, the model will use a replicated voice for the response.
63+
*/
64+
@JsonProperty("replicatedVoiceConfig")
65+
public abstract Builder replicatedVoiceConfig(ReplicatedVoiceConfig replicatedVoiceConfig);
66+
67+
/**
68+
* Setter for replicatedVoiceConfig builder.
69+
*
70+
* <p>replicatedVoiceConfig: If true, the model will use a replicated voice for the response.
71+
*/
72+
@CanIgnoreReturnValue
73+
public Builder replicatedVoiceConfig(
74+
ReplicatedVoiceConfig.Builder replicatedVoiceConfigBuilder) {
75+
return replicatedVoiceConfig(replicatedVoiceConfigBuilder.build());
76+
}
77+
78+
@ExcludeFromGeneratedCoverageReport
79+
abstract Builder replicatedVoiceConfig(Optional<ReplicatedVoiceConfig> replicatedVoiceConfig);
80+
81+
/** Clears the value of replicatedVoiceConfig field. */
82+
@ExcludeFromGeneratedCoverageReport
83+
@CanIgnoreReturnValue
84+
public Builder clearReplicatedVoiceConfig() {
85+
return replicatedVoiceConfig(Optional.empty());
86+
}
87+
5588
/**
5689
* Setter for prebuiltVoiceConfig.
5790
*

0 commit comments

Comments
 (0)