@@ -142,7 +142,7 @@ DefaultAzureCredential credential = new DefaultAzureCredential();
142
142
VoiceLiveClient client = new VoiceLiveClient (endpoint , credential );
143
143
144
144
// Start a new session
145
- VoiceLiveSession session = await client .StartSessionAsync ();
145
+ VoiceLiveSession session = await client .StartSessionAsync (). ConfigureAwait ( false ) ;
146
146
147
147
// Configure session for voice conversation
148
148
ConversationSessionOptions sessionOptions = new ConversationSessionOptions ()
@@ -165,10 +165,10 @@ sessionOptions.Modalities.Clear();
165
165
sessionOptions .Modalities .Add (InputModality .Text );
166
166
sessionOptions .Modalities .Add (InputModality .Audio );
167
167
168
- await session .ConfigureConversationSessionAsync (sessionOptions );
168
+ await session .ConfigureConversationSessionAsync (sessionOptions ). ConfigureAwait ( false ) ;
169
169
170
170
// Process events from the session
171
- await foreach (ServerEvent serverEvent in session .ReceiveEventsAsync ( ))
171
+ await foreach (ServerEvent serverEvent in session .GetUpdatesAsync (). ConfigureAwait ( false ))
172
172
{
173
173
if (serverEvent is ServerEventResponseAudioDelta audioDelta )
174
174
{
@@ -191,9 +191,8 @@ ConversationSessionOptions sessionOptions = new ConversationSessionOptions()
191
191
{
192
192
Model = " gpt-4o-realtime-preview" ,
193
193
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 )
195
195
{
196
- EndpointId = " your-custom-voice-endpoint-id" ,
197
196
Temperature = 0 . 8 f
198
197
},
199
198
TurnDetection = new AzureSemanticVad ()
@@ -211,16 +210,15 @@ sessionOptions.Modalities.Clear();
211
210
sessionOptions .Modalities .Add (InputModality .Text );
212
211
sessionOptions .Modalities .Add (InputModality .Audio );
213
212
214
- await session .ConfigureConversationSessionAsync (sessionOptions );
213
+ await session .ConfigureConversationSessionAsync (sessionOptions ). ConfigureAwait ( false ) ;
215
214
```
216
215
217
216
### Function calling example
218
217
219
218
``` C# Snippet:FunctionCallingExample
220
219
// Define a function for the assistant to call
221
- var getCurrentWeatherFunction = new FunctionTool
220
+ var getCurrentWeatherFunction = new FunctionTool ( " get_current_weather " )
222
221
{
223
- Name = " get_current_weather" ,
224
222
Description = " Get the current weather for a given location" ,
225
223
Parameters = BinaryData .FromString ("""
226
224
{
@@ -253,7 +251,7 @@ sessionOptions.Modalities.Clear();
253
251
sessionOptions .Modalities .Add (InputModality .Text );
254
252
sessionOptions .Modalities .Add (InputModality .Audio );
255
253
256
- await session .ConfigureConversationSessionAsync (sessionOptions );
254
+ await session .ConfigureConversationSessionAsync (sessionOptions ). ConfigureAwait ( false ) ;
257
255
```
258
256
259
257
## Troubleshooting
0 commit comments