Skip to content

Commit b3abbf3

Browse files
yyyu-googlecopybara-github
authored andcommitted
feat: enable language code for audio transcription config in Live API for Vertex AI
PiperOrigin-RevId: 875498260
1 parent ee83da6 commit b3abbf3

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

GeneratedFirebaseAI/Sources/Types.swift

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34355,24 +34355,50 @@ extension ContextWindowCompressionConfig: Codable {
3435534355
/// The audio transcription configuration in Setup.
3435634356
@available(iOS 15.0, macOS 13.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
3435734357
public struct AudioTranscriptionConfig: Sendable {
34358+
/// The language codes of the audio. BCP-47 language code. If not set, the
34359+
/// transcription will be in the language detected by the model. If set, the server
34360+
/// will use the language code specified in the model config as a hint for the
34361+
/// language of the audio
34362+
public let languageCodes: [String]?
3435834363

3435934364
/// Default initializer.
34360-
public init() {
34361-
34365+
public init(
34366+
languageCodes: [String]? = nil
34367+
) {
34368+
self.languageCodes = languageCodes
3436234369
}
3436334370
}
3436434371

3436534372
@available(iOS 15.0, macOS 13.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
3436634373
extension AudioTranscriptionConfig: Codable {
3436734374

3436834375
// MARK: - Codable
34376+
public enum VertexKeys: String, CodingKey {
34377+
case languageCodes = "languageCodes"
34378+
}
3436934379

3437034380
public init(from decoder: any Decoder) throws {
3437134381
let configuration: APIClient = try decoder.userInfoOrThrow(.configuration)
34382+
34383+
let VertexKeysContainer = try decoder.container(keyedBy: VertexKeys.self)
34384+
languageCodes = try VertexKeysContainer.decodeIfPresent(
34385+
[String].self,
34386+
forKey: .languageCodes
34387+
)
3437234388
}
3437334389

3437434390
public func encode(to encoder: any Encoder) throws {
3437534391
let configuration: APIClient = try encoder.userInfoOrThrow(.configuration)
34392+
34393+
if configuration.isVertexAI() {
34394+
34395+
var VertexKeysContainer = encoder.container(keyedBy: VertexKeys.self)
34396+
try VertexKeysContainer.encodeIfPresent(
34397+
languageCodes,
34398+
forKey: .languageCodes
34399+
)
34400+
34401+
}
3437634402
}
3437734403
}
3437834404

0 commit comments

Comments
 (0)