Skip to content

Commit 7621aab

Browse files
committed
Update snippets in readme's
1 parent 9542c54 commit 7621aab

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

sdk/ai/Azure.AI.VoiceLive/README.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ DefaultAzureCredential credential = new DefaultAzureCredential();
142142
VoiceLiveClient 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
148148
ConversationSessionOptions sessionOptions = new ConversationSessionOptions()
@@ -165,10 +165,10 @@ sessionOptions.Modalities.Clear();
165165
sessionOptions.Modalities.Add(InputModality.Text);
166166
sessionOptions.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.8f
198197
},
199198
TurnDetection = new AzureSemanticVad()
@@ -211,16 +210,15 @@ sessionOptions.Modalities.Clear();
211210
sessionOptions.Modalities.Add(InputModality.Text);
212211
sessionOptions.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();
253251
sessionOptions.Modalities.Add(InputModality.Text);
254252
sessionOptions.Modalities.Add(InputModality.Audio);
255253

256-
await session.ConfigureConversationSessionAsync(sessionOptions);
254+
await session.ConfigureConversationSessionAsync(sessionOptions).ConfigureAwait(false);
257255
```
258256

259257
## Troubleshooting

sdk/ai/Azure.AI.VoiceLive/samples/snippets/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,7 @@ VoiceLiveClient client = new VoiceLiveClient(endpoint, credential);
3131
These snippets are then referenced in the README using the syntax:
3232
```markdown
3333
```C# Snippet:CreateVoiceLiveClientWithApiKey
34+
Uri endpoint = new Uri("https://your-resource.cognitiveservices.azure.com");
35+
AzureKeyCredential credential = new AzureKeyCredential("your-api-key");
36+
VoiceLiveClient client = new VoiceLiveClient(endpoint, credential);
3437
```

0 commit comments

Comments
 (0)