Skip to content

Commit 4156ee6

Browse files
committed
update voice
1 parent 4e027a9 commit 4156ee6

File tree

2 files changed

+13
-33
lines changed

2 files changed

+13
-33
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ 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: Voices,
2727
) {
2828

2929
@Serializable

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

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,37 +19,17 @@ package com.google.firebase.ai.type
1919
import kotlinx.serialization.SerialName
2020
import kotlinx.serialization.Serializable
2121

22-
/** Various voices supported by the server */
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+
*/
2326
@PublicPreviewAPI
24-
public class Voices private constructor(public val ordinal: Int) {
27+
public class Voices public constructor(public val voiceName: String) {
2528

2629
@Serializable internal data class Internal(@SerialName("voice_name") val voiceName: String)
2730

28-
@Serializable
29-
internal enum class InternalEnum {
30-
CHARON,
31-
AOEDE,
32-
FENRIR,
33-
KORE,
34-
PUCK;
35-
internal fun toPublic() =
36-
when (this) {
37-
CHARON -> Voices.CHARON
38-
AOEDE -> Voices.AOEDE
39-
FENRIR -> Voices.FENRIR
40-
KORE -> Voices.KORE
41-
else -> Voices.PUCK
42-
}
43-
}
44-
4531
internal fun toInternal(): Internal {
46-
return when (this) {
47-
CHARON -> Internal(InternalEnum.CHARON.name)
48-
AOEDE -> Internal(InternalEnum.AOEDE.name)
49-
FENRIR -> Internal(InternalEnum.FENRIR.name)
50-
KORE -> Internal(InternalEnum.KORE.name)
51-
else -> Internal(InternalEnum.PUCK.name)
52-
}
32+
return Internal(this.voiceName)
5333
}
5434

5535
public companion object {
@@ -58,21 +38,21 @@ public class Voices private constructor(public val ordinal: Int) {
5838
*
5939
* Will use the default voice of the model.
6040
*/
61-
@JvmField public val UNSPECIFIED: Voices = Voices(0)
41+
@JvmField public val UNSPECIFIED: Voices = Voices("Puck")
6242

6343
/** Represents the Charon voice. */
64-
@JvmField public val CHARON: Voices = Voices(1)
44+
@JvmField public val CHARON: Voices = Voices("Charon")
6545

6646
/** Represents the Aoede voice. */
67-
@JvmField public val AOEDE: Voices = Voices(2)
47+
@JvmField public val AOEDE: Voices = Voices("Aoede")
6848

6949
/** Represents the Fenrir voice. */
70-
@JvmField public val FENRIR: Voices = Voices(3)
50+
@JvmField public val FENRIR: Voices = Voices("Fenrir")
7151

7252
/** Represents the Kore voice. */
73-
@JvmField public val KORE: Voices = Voices(4)
53+
@JvmField public val KORE: Voices = Voices("Kore")
7454

7555
/** Represents the Puck voice. */
76-
@JvmField public val PUCK: Voices = Voices(5)
56+
@JvmField public val PUCK: Voices = Voices("Puck")
7757
}
7858
}

0 commit comments

Comments
 (0)