Skip to content

Commit d7c97c6

Browse files
VinayGuthalemilypgoogle
authored andcommitted
update voice (#6996)
This pr updates the Voice class to take in a string as an attribute instead of just an enum. This is a breaking change since it breaks binary compatibility however I don't think there is any changes that need to be done by the developer
1 parent 2bd3756 commit d7c97c6

File tree

7 files changed

+65
-20
lines changed

7 files changed

+65
-20
lines changed

firebase-ai/CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Unreleased
22

33
* [fixed] Fixed `FirebaseAI.getInstance` StackOverflowException (#6971)
4-
* [fixed] Fixed an issue that was causing the SDK to send empty `FunctionDeclaration` descriptions to the API.
4+
* [fixed] Fixed an issue that was causing the SDK to send empty `FunctionDeclaration` descriptions to the API.
5+
* [changed] Introduced the `Voice` class, which accepts a voice name, and deprecated the `Voices` class.
6+
* [changed] **Breaking Change**: Updated `SpeechConfig` to take in `Voice` class instead of `Voices` class.
7+
* **Action Required:** Update all references of `SpeechConfig` initialization to use `Voice` class.
58

9+
610
# 16.0.0
711
* [feature] Initial release of the Firebase AI SDK (`firebase-ai`). This SDK *replaces* the previous
812
Vertex AI in Firebase SDK (`firebase-vertexai`) to accommodate the evolving set of supported

firebase-ai/api.txt

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -863,9 +863,9 @@ package com.google.firebase.ai.type {
863863
}
864864

865865
@com.google.firebase.ai.type.PublicPreviewAPI public final class SpeechConfig {
866-
ctor public SpeechConfig(com.google.firebase.ai.type.Voices voice);
867-
method public com.google.firebase.ai.type.Voices getVoice();
868-
property public final com.google.firebase.ai.type.Voices voice;
866+
ctor public SpeechConfig(com.google.firebase.ai.type.Voice voice);
867+
method public com.google.firebase.ai.type.Voice getVoice();
868+
property public final com.google.firebase.ai.type.Voice voice;
869869
}
870870

871871
public abstract class StringFormat {
@@ -914,19 +914,25 @@ package com.google.firebase.ai.type {
914914
property public final int totalTokenCount;
915915
}
916916

917-
@com.google.firebase.ai.type.PublicPreviewAPI public final class Voices {
918-
method public int getOrdinal();
919-
property public final int ordinal;
920-
field public static final com.google.firebase.ai.type.Voices AOEDE;
921-
field public static final com.google.firebase.ai.type.Voices CHARON;
922-
field public static final com.google.firebase.ai.type.Voices.Companion Companion;
923-
field public static final com.google.firebase.ai.type.Voices FENRIR;
924-
field public static final com.google.firebase.ai.type.Voices KORE;
925-
field public static final com.google.firebase.ai.type.Voices PUCK;
926-
field public static final com.google.firebase.ai.type.Voices UNSPECIFIED;
917+
@com.google.firebase.ai.type.PublicPreviewAPI public final class Voice {
918+
ctor public Voice(String voiceName);
919+
method public String getVoiceName();
920+
property public final String voiceName;
921+
}
922+
923+
@Deprecated @com.google.firebase.ai.type.PublicPreviewAPI public final class Voices {
924+
method @Deprecated public int getOrdinal();
925+
property @Deprecated public final int ordinal;
926+
field @Deprecated public static final com.google.firebase.ai.type.Voices AOEDE;
927+
field @Deprecated public static final com.google.firebase.ai.type.Voices CHARON;
928+
field @Deprecated public static final com.google.firebase.ai.type.Voices.Companion Companion;
929+
field @Deprecated public static final com.google.firebase.ai.type.Voices FENRIR;
930+
field @Deprecated public static final com.google.firebase.ai.type.Voices KORE;
931+
field @Deprecated public static final com.google.firebase.ai.type.Voices PUCK;
932+
field @Deprecated public static final com.google.firebase.ai.type.Voices UNSPECIFIED;
927933
}
928934

929-
public static final class Voices.Companion {
935+
@Deprecated public static final class Voices.Companion {
930936
}
931937

932938
}

firebase-ai/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
version=16.0.1
15+
version=16.1.0
1616
latestReleasedVersion=16.0.0

firebase-ai/src/main/kotlin/com/google/firebase/ai/type/SpeechConfig.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ import kotlinx.serialization.Serializable
2323
@PublicPreviewAPI
2424
public class SpeechConfig(
2525
/** The voice to be used for the server's speech response. */
26-
public val voice: Voices
26+
public val voice: Voice
2727
) {
2828

2929
@Serializable
3030
internal data class Internal(@SerialName("voice_config") val voiceConfig: VoiceConfigInternal) {
3131
@Serializable
3232
internal data class VoiceConfigInternal(
33-
@SerialName("prebuilt_voice_config") val prebuiltVoiceConfig: Voices.Internal,
33+
@SerialName("prebuilt_voice_config") val prebuiltVoiceConfig: Voice.Internal,
3434
)
3535
}
3636

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
* http://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+
package com.google.firebase.ai.type
18+
19+
import kotlinx.serialization.SerialName
20+
import kotlinx.serialization.Serializable
21+
22+
/**
23+
* Various voices supported by the server. The list of all voices can be found
24+
* [here](https://cloud.google.com/text-to-speech/docs/chirp3-hd)
25+
*/
26+
@PublicPreviewAPI
27+
public class Voice public constructor(public val voiceName: String) {
28+
29+
@Serializable internal data class Internal(@SerialName("voice_name") val voiceName: String)
30+
31+
internal fun toInternal(): Internal {
32+
return Internal(this.voiceName)
33+
}
34+
}

firebase-ai/src/main/kotlin/com/google/firebase/ai/type/Voices.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import kotlinx.serialization.SerialName
2020
import kotlinx.serialization.Serializable
2121

2222
/** Various voices supported by the server */
23+
@Deprecated("Please use the Voice class instead.", ReplaceWith("Voice"))
2324
@PublicPreviewAPI
2425
public class Voices private constructor(public val ordinal: Int) {
2526

firebase-ai/src/testUtil/java/com/google/firebase/ai/JavaCompileTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
import com.google.firebase.ai.type.SpeechConfig;
6262
import com.google.firebase.ai.type.TextPart;
6363
import com.google.firebase.ai.type.UsageMetadata;
64-
import com.google.firebase.ai.type.Voices;
64+
import com.google.firebase.ai.type.Voice;
6565
import com.google.firebase.concurrent.FirebaseExecutors;
6666
import java.util.ArrayList;
6767
import java.util.Calendar;
@@ -137,7 +137,7 @@ private LiveGenerationConfig getLiveConfig() {
137137
.setFrequencyPenalty(1.0F)
138138
.setPresencePenalty(2.0F)
139139
.setResponseModality(ResponseModality.AUDIO)
140-
.setSpeechConfig(new SpeechConfig(Voices.AOEDE))
140+
.setSpeechConfig(new SpeechConfig(new Voice("AOEDE")))
141141
.build();
142142
}
143143

0 commit comments

Comments
 (0)