2020
2121namespace Firebase . AI {
2222
23+ /// <summary>
24+ /// A struct used to configure speech generation settings.
25+ /// </summary>
26+ public readonly struct SpeechConfig
27+ {
28+ internal readonly string voice ;
29+
30+ private SpeechConfig ( string voice )
31+ {
32+ this . voice = voice ;
33+ }
34+
35+ /// <summary>
36+ /// See https://cloud.google.com/text-to-speech/docs/chirp3-hd for the list of available voices.
37+ /// </summary>
38+ /// <param name="voice"></param>
39+ /// <returns></returns>
40+ public static SpeechConfig UsePrebuiltVoice ( string voice )
41+ {
42+ return new SpeechConfig ( voice ) ;
43+ }
44+
45+ /// <summary>
46+ /// Intended for internal use only.
47+ /// This method is used for serializing the object to JSON for the API request.
48+ /// </summary>
49+ internal Dictionary < string , object > ToJson ( )
50+ {
51+ Dictionary < string , object > dict = new ( ) ;
52+
53+ if ( ! string . IsNullOrWhiteSpace ( voice ) )
54+ {
55+ dict [ "voiceConfig" ] = new Dictionary < string , object > ( ) {
56+ { "prebuiltVoiceConfig" , new Dictionary < string , object > ( ) {
57+ { "voiceName" , voice }
58+ } }
59+ } ;
60+ }
61+
62+ return dict ;
63+ }
64+ }
65+
2366/// <summary>
24- /// A struct used to configure speech generation settings.
67+ /// A struct used to configure speech transcription settings.
2568/// </summary>
26- public readonly struct SpeechConfig {
27- internal readonly string voice ;
69+ public readonly struct AudioTranscriptionConfig {
2870
29- private SpeechConfig ( string voice ) {
30- this . voice = voice ;
71+ private AudioTranscriptionConfig ( ) {
3172 }
3273
3374 /// <summary>
34- /// See https://cloud.google.com/text-to-speech/docs/chirp3-hd for the list of available voices .
75+ /// Creates a new transcription configuration .
3576 /// </summary>
36- /// <param name="voice"></param>
37- /// <returns></returns>
38- public static SpeechConfig UsePrebuiltVoice ( string voice ) {
39- return new SpeechConfig ( voice ) ;
77+ /// <returns>A new transcription configuration.</returns>
78+ public static AudioTranscriptionConfig GetInstance ( ) {
79+ return new AudioTranscriptionConfig ( ) ;
4080 }
4181
4282 /// <summary>
@@ -45,15 +85,6 @@ public static SpeechConfig UsePrebuiltVoice(string voice) {
4585 /// </summary>
4686 internal Dictionary < string , object > ToJson ( ) {
4787 Dictionary < string , object > dict = new ( ) ;
48-
49- if ( ! string . IsNullOrWhiteSpace ( voice ) ) {
50- dict [ "voiceConfig" ] = new Dictionary < string , object > ( ) {
51- { "prebuiltVoiceConfig" , new Dictionary < string , object > ( ) {
52- { "voiceName" , voice }
53- } }
54- } ;
55- }
56-
5788 return dict ;
5889 }
5990}
@@ -62,6 +93,8 @@ internal Dictionary<string, object> ToJson() {
6293/// A struct defining model parameters to be used when generating live session content.
6394/// </summary>
6495public readonly struct LiveGenerationConfig {
96+ private readonly AudioTranscriptionConfig ? _inputAudioTranscription ;
97+ private readonly AudioTranscriptionConfig ? _outputAudioTranscription ;
6598 private readonly SpeechConfig ? _speechConfig ;
6699 private readonly List < ResponseModality > _responseModalities ;
67100 private readonly float ? _temperature ;
@@ -81,6 +114,10 @@ public readonly struct LiveGenerationConfig {
81114 /// for more details.
82115 /// </summary>
83116 ///
117+ /// <param name="inputAudioTranscription">The transcription configuration to use if transcribing audio input.</param>
118+ ///
119+ /// <param name="outputAudioTranscription">The transcription configuration to use if transcribing audio output.</param>
120+ ///
84121 /// <param name="speechConfig">The speech configuration to use if generating audio output.</param>
85122 ///
86123 /// <param name="responseModalities">A list of response types to receive from the model.
@@ -155,6 +192,8 @@ public readonly struct LiveGenerationConfig {
155192 /// [Cloud documentation](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/inference#generationconfig)
156193 /// for more details.</param>
157194 public LiveGenerationConfig (
195+ AudioTranscriptionConfig ? inputAudioTranscription = null ,
196+ AudioTranscriptionConfig ? outputAudioTranscription = null ,
158197 SpeechConfig ? speechConfig = null ,
159198 IEnumerable < ResponseModality > responseModalities = null ,
160199 float ? temperature = null ,
@@ -163,6 +202,8 @@ public LiveGenerationConfig(
163202 int ? maxOutputTokens = null ,
164203 float ? presencePenalty = null ,
165204 float ? frequencyPenalty = null ) {
205+ _inputAudioTranscription = inputAudioTranscription ;
206+ _outputAudioTranscription = outputAudioTranscription ;
166207 _speechConfig = speechConfig ;
167208 _responseModalities = responseModalities != null ?
168209 new List < ResponseModality > ( responseModalities ) : new List < ResponseModality > ( ) ;
@@ -178,8 +219,11 @@ public LiveGenerationConfig(
178219 /// Intended for internal use only.
179220 /// This method is used for serializing the object to JSON for the API request.
180221 /// </summary>
181- internal Dictionary < string , object > ToJson ( ) {
222+ internal Dictionary < string , object > ToJson ( )
223+ {
182224 Dictionary < string , object > jsonDict = new ( ) ;
225+ if ( _inputAudioTranscription . HasValue ) jsonDict [ "inputAudioTranscription" ] = _inputAudioTranscription ? . ToJson ( ) ;
226+ if ( _outputAudioTranscription . HasValue ) jsonDict [ "outputAudioTranscription" ] = _outputAudioTranscription ? . ToJson ( ) ;
183227 if ( _speechConfig . HasValue ) jsonDict [ "speechConfig" ] = _speechConfig ? . ToJson ( ) ;
184228 if ( _responseModalities != null && _responseModalities . Any ( ) ) {
185229 jsonDict [ "responseModalities" ] =
0 commit comments