@@ -142,7 +142,7 @@ DefaultAzureCredential credential = new DefaultAzureCredential();
142142VoiceLiveClient client = new VoiceLiveClient (endpoint , credential );
143143
144144// Start a new session
145- VoiceLiveSession session = await client .StartSessionAsync ();
145+ VoiceLiveSession session = await client .StartSessionAsync (). ConfigureAwait ( false ) ;
146146
147147// Configure session for voice conversation
148148ConversationSessionOptions sessionOptions = new ConversationSessionOptions ()
@@ -165,10 +165,10 @@ sessionOptions.Modalities.Clear();
165165sessionOptions .Modalities .Add (InputModality .Text );
166166sessionOptions .Modalities .Add (InputModality .Audio );
167167
168- await session .ConfigureConversationSessionAsync (sessionOptions );
168+ await session .ConfigureConversationSessionAsync (sessionOptions ). ConfigureAwait ( false ) ;
169169
170170// Process events from the session
171- await foreach (ServerEvent serverEvent in session .ReceiveEventsAsync ( ))
171+ await foreach (ServerEvent serverEvent in session .GetUpdatesAsync (). ConfigureAwait ( false ))
172172{
173173 if (serverEvent is ServerEventResponseAudioDelta audioDelta )
174174 {
@@ -191,9 +191,8 @@ ConversationSessionOptions sessionOptions = new ConversationSessionOptions()
191191{
192192 Model = " gpt-4o-realtime-preview" ,
193193 Instructions = " You are a customer service representative. Be helpful and professional." ,
194- Voice = new AzureCustomVoice (" your-custom-voice-name" , AzureCustomVoiceType .AzureCustom )
194+ Voice = new AzureCustomVoice (" your-custom-voice-name" , " your-custom-voice-endpoint-id " , AzureCustomVoiceType .AzureCustom )
195195 {
196- EndpointId = " your-custom-voice-endpoint-id" ,
197196 Temperature = 0 . 8 f
198197 },
199198 TurnDetection = new AzureSemanticVad ()
@@ -211,16 +210,15 @@ sessionOptions.Modalities.Clear();
211210sessionOptions .Modalities .Add (InputModality .Text );
212211sessionOptions .Modalities .Add (InputModality .Audio );
213212
214- await session .ConfigureConversationSessionAsync (sessionOptions );
213+ await session .ConfigureConversationSessionAsync (sessionOptions ). ConfigureAwait ( false ) ;
215214```
216215
217216### Function calling example
218217
219218``` C# Snippet:FunctionCallingExample
220219// Define a function for the assistant to call
221- var getCurrentWeatherFunction = new FunctionTool
220+ var getCurrentWeatherFunction = new FunctionTool ( " get_current_weather " )
222221{
223- Name = " get_current_weather" ,
224222 Description = " Get the current weather for a given location" ,
225223 Parameters = BinaryData .FromString ("""
226224 {
@@ -253,7 +251,7 @@ sessionOptions.Modalities.Clear();
253251sessionOptions .Modalities .Add (InputModality .Text );
254252sessionOptions .Modalities .Add (InputModality .Audio );
255253
256- await session .ConfigureConversationSessionAsync (sessionOptions );
254+ await session .ConfigureConversationSessionAsync (sessionOptions ). ConfigureAwait ( false ) ;
257255```
258256
259257## Troubleshooting
0 commit comments