@@ -61,6 +61,9 @@ public struct GenerationConfig: Sendable, Equatable {
6161 /// Configuration options for generating images.
6262 var imageConfig : ImageConfig ?
6363
64+ /// Configuration for controlling the voice of the model during conversation.
65+ var speechConfig : ProtoSpeechConfig ?
66+
6467 /// Creates a new `GenerationConfig` value.
6568 ///
6669 /// See the
@@ -164,13 +167,16 @@ public struct GenerationConfig: Sendable, Equatable {
164167 /// > backwards-incompatible ways.
165168 /// - thinkingConfig: Configuration for controlling the "thinking" behavior of compatible Gemini
166169 /// models; see ``ThinkingConfig`` for more details.
170+ /// - speechConfig: Configuration for controlling the voice of the model during conversation;
171+ /// see ``SpeechConfig`` for more details.
167172 /// - imageConfig: Configuration options for generating images.
168173 public init ( temperature: Float ? = nil , topP: Float ? = nil , topK: Int ? = nil ,
169174 candidateCount: Int ? = nil , maxOutputTokens: Int ? = nil ,
170175 presencePenalty: Float ? = nil , frequencyPenalty: Float ? = nil ,
171176 stopSequences: [ String ] ? = nil , responseMIMEType: String ? = nil ,
172177 responseSchema: Schema ? = nil , responseModalities: [ ResponseModality ] ? = nil ,
173- thinkingConfig: ThinkingConfig ? = nil , imageConfig: ImageConfig ? = nil ) {
178+ thinkingConfig: ThinkingConfig ? = nil , imageConfig: ImageConfig ? = nil ,
179+ speechConfig: SpeechConfig ? = nil ) {
174180 // Explicit init because otherwise if we re-arrange the above variables it changes the API
175181 // surface.
176182 self . temperature = temperature
@@ -187,13 +193,14 @@ public struct GenerationConfig: Sendable, Equatable {
187193 self . responseModalities = responseModalities
188194 self . thinkingConfig = thinkingConfig
189195 self . imageConfig = imageConfig
196+ self . speechConfig = speechConfig? . speechConfig
190197 }
191198
192199 init ( temperature: Float ? = nil , topP: Float ? = nil , topK: Int ? = nil , candidateCount: Int ? = nil ,
193200 maxOutputTokens: Int ? = nil , presencePenalty: Float ? = nil , frequencyPenalty: Float ? = nil ,
194201 stopSequences: [ String ] ? = nil , responseMIMEType: String , responseJSONSchema: JSONObject ,
195202 responseModalities: [ ResponseModality ] ? = nil , thinkingConfig: ThinkingConfig ? = nil ,
196- imageConfig: ImageConfig ? = nil ) {
203+ imageConfig: ImageConfig ? = nil , speechConfig : SpeechConfig ? = nil ) {
197204 self . temperature = temperature
198205 self . topP = topP
199206 self . topK = topK
@@ -207,6 +214,7 @@ public struct GenerationConfig: Sendable, Equatable {
207214 self . responseJSONSchema = responseJSONSchema
208215 self . responseModalities = responseModalities
209216 self . thinkingConfig = thinkingConfig
217+ self . speechConfig = speechConfig? . speechConfig
210218 self . imageConfig = imageConfig
211219 }
212220
@@ -246,6 +254,7 @@ public struct GenerationConfig: Sendable, Equatable {
246254 config. responseModalities = overrideConfig. responseModalities ?? config. responseModalities
247255 config. thinkingConfig = overrideConfig. thinkingConfig ?? config. thinkingConfig
248256 config. imageConfig = overrideConfig. imageConfig ?? config. imageConfig
257+ config. speechConfig = overrideConfig. speechConfig ?? config. speechConfig
249258
250259 // 5. Handle Schema mutual exclusivity with precedence for `responseJSONSchema`.
251260 if let responseJSONSchema = overrideConfig. responseJSONSchema {
@@ -278,5 +287,6 @@ extension GenerationConfig: Encodable {
278287 case responseModalities
279288 case thinkingConfig
280289 case imageConfig
290+ case speechConfig
281291 }
282292}
0 commit comments