@@ -26,7 +26,7 @@ public async Task BasicVoiceAssistantExample()
26
26
VoiceLiveClient client = new VoiceLiveClient ( endpoint , credential ) ;
27
27
28
28
// Start a new session
29
- VoiceLiveSession session = await client . StartSessionAsync ( ) ;
29
+ VoiceLiveSession session = await client . StartSessionAsync ( ) . ConfigureAwait ( false ) ;
30
30
31
31
// Configure session for voice conversation
32
32
ConversationSessionOptions sessionOptions = new ConversationSessionOptions ( )
@@ -49,10 +49,10 @@ public async Task BasicVoiceAssistantExample()
49
49
sessionOptions . Modalities . Add ( InputModality . Text ) ;
50
50
sessionOptions . Modalities . Add ( InputModality . Audio ) ;
51
51
52
- await session . ConfigureConversationSessionAsync ( sessionOptions ) ;
52
+ await session . ConfigureConversationSessionAsync ( sessionOptions ) . ConfigureAwait ( false ) ;
53
53
54
54
// Process events from the session
55
- await foreach ( ServerEvent serverEvent in session . ReceiveEventsAsync ( ) )
55
+ await foreach ( ServerEvent serverEvent in session . GetUpdatesAsync ( ) . ConfigureAwait ( false ) )
56
56
{
57
57
if ( serverEvent is ServerEventResponseAudioDelta audioDelta )
58
58
{
@@ -77,16 +77,15 @@ public async Task AdvancedVoiceConfiguration()
77
77
Uri endpoint = new Uri ( "https://your-resource.cognitiveservices.azure.com" ) ;
78
78
DefaultAzureCredential credential = new DefaultAzureCredential ( ) ;
79
79
VoiceLiveClient client = new VoiceLiveClient ( endpoint , credential ) ;
80
- VoiceLiveSession session = await client . StartSessionAsync ( ) ;
80
+ VoiceLiveSession session = await client . StartSessionAsync ( ) . ConfigureAwait ( false ) ;
81
81
82
82
#region Snippet:AdvancedVoiceConfiguration
83
83
ConversationSessionOptions sessionOptions = new ConversationSessionOptions ( )
84
84
{
85
85
Model = "gpt-4o-realtime-preview" ,
86
86
Instructions = "You are a customer service representative. Be helpful and professional." ,
87
- Voice = new AzureCustomVoice ( "your-custom-voice-name" , AzureCustomVoiceType . AzureCustom )
87
+ Voice = new AzureCustomVoice ( "your-custom-voice-name" , "your-custom-voice-endpoint-id" , AzureCustomVoiceType . AzureCustom )
88
88
{
89
- EndpointId = "your-custom-voice-endpoint-id" ,
90
89
Temperature = 0.8f
91
90
} ,
92
91
TurnDetection = new AzureSemanticVad ( )
@@ -104,7 +103,7 @@ public async Task AdvancedVoiceConfiguration()
104
103
sessionOptions . Modalities . Add ( InputModality . Text ) ;
105
104
sessionOptions . Modalities . Add ( InputModality . Audio ) ;
106
105
107
- await session . ConfigureConversationSessionAsync ( sessionOptions ) ;
106
+ await session . ConfigureConversationSessionAsync ( sessionOptions ) . ConfigureAwait ( false ) ;
108
107
#endregion
109
108
}
110
109
@@ -116,13 +115,12 @@ public async Task FunctionCallingExample()
116
115
Uri endpoint = new Uri ( "https://your-resource.cognitiveservices.azure.com" ) ;
117
116
DefaultAzureCredential credential = new DefaultAzureCredential ( ) ;
118
117
VoiceLiveClient client = new VoiceLiveClient ( endpoint , credential ) ;
119
- VoiceLiveSession session = await client . StartSessionAsync ( ) ;
118
+ VoiceLiveSession session = await client . StartSessionAsync ( ) . ConfigureAwait ( false ) ;
120
119
121
120
#region Snippet:FunctionCallingExample
122
121
// Define a function for the assistant to call
123
- var getCurrentWeatherFunction = new FunctionTool
122
+ var getCurrentWeatherFunction = new FunctionTool ( "get_current_weather" )
124
123
{
125
- Name = "get_current_weather" ,
126
124
Description = "Get the current weather for a given location" ,
127
125
Parameters = BinaryData . FromString ( """
128
126
{
@@ -155,8 +153,8 @@ public async Task FunctionCallingExample()
155
153
sessionOptions . Modalities . Add ( InputModality . Text ) ;
156
154
sessionOptions . Modalities . Add ( InputModality . Audio ) ;
157
155
158
- await session . ConfigureConversationSessionAsync ( sessionOptions ) ;
156
+ await session . ConfigureConversationSessionAsync ( sessionOptions ) . ConfigureAwait ( false ) ;
159
157
#endregion
160
158
}
161
159
}
162
- }
160
+ }
0 commit comments