Skip to content

Commit 7fa5304

Browse files
committed
Getting closer
1 parent d6b064b commit 7fa5304

File tree

7 files changed

+75
-43
lines changed

7 files changed

+75
-43
lines changed

sdk/ai/Azure.AI.VoiceLive/samples/CustomerServiceBot/AudioProcessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public Task StartCaptureAsync()
100100

101101
_logger.LogInformation($"{i}: {deviceInfo.ProductName}");
102102
}
103-
_waveIn.DeviceNumber = 1;
103+
_waveIn.DeviceNumber = 0; // Default to first device
104104

105105
_waveIn.StartRecording();
106106

sdk/ai/Azure.AI.VoiceLive/samples/CustomerServiceBot/CustomerServiceBot.cs

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -469,26 +469,11 @@ private async Task HandleServerEventAsync(ServerEvent serverEvent, CancellationT
469469
break;
470470
case ServerEventResponseDone responseDone:
471471
_logger.LogInformation("✅ Response complete");
472+
break;
473+
case ServerEventResponseFunctionCallArgumentsDone functionCallArgumentsDone:
474+
_logger.LogInformation("🔧 Function call arguments done for call ID: {CallId}", functionCallArgumentsDone.CallId);
475+
await HandleFunctionCallAsync(functionCallArgumentsDone.Name, functionCallArgumentsDone.CallId, functionCallArgumentsDone.Arguments, cancellationToken);
472476

473-
// We could have assembled a function call on the fly from delta notifications, but since these function
474-
// calls would not benefit from partial information we're going to wait for the entire call to be here
475-
// before doing anything with it.
476-
foreach(var responseItem in responseDone.Response.Output)
477-
{
478-
switch (responseItem)
479-
{
480-
case ResponseMessageItem messageItem:
481-
482-
// In addition to the audio, write the assistants
483-
if(messageItem.Role == MessageRole.Assistant)
484-
{
485-
486-
}
487-
break;
488-
case ResponseFunctionCallItem functionCall:
489-
break;
490-
}
491-
}
492477
break;
493478
case ServerEventResponseAudioTranscriptDelta transcriptDelta:
494479
// For now, only deal with the assistant responses.
@@ -497,6 +482,14 @@ private async Task HandleServerEventAsync(ServerEvent serverEvent, CancellationT
497482
Console.Write($"{transcriptDelta.Delta}");
498483
}
499484
break;
485+
486+
case ServerEventResponseAudioTranscriptDone transcriptDone:
487+
// For now, only deal with the assistant responses.
488+
if (_assistantMessageResponses.Contains(transcriptDone.ResponseId))
489+
{
490+
Console.WriteLine();
491+
}
492+
break;
500493
case ServerEventError errorEvent:
501494
_logger.LogError("❌ VoiceLive error: {ErrorMessage}", errorEvent.Error?.Message);
502495
Console.WriteLine($"Error: {errorEvent.Error?.Message}");

sdk/ai/Azure.AI.VoiceLive/src/Generated/AIVoiceLiveModelFactory.cs

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/ai/Azure.AI.VoiceLive/src/Generated/ServerEventResponseFunctionCallArgumentsDone.Serialization.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/ai/Azure.AI.VoiceLive/src/Generated/ServerEventResponseFunctionCallArgumentsDone.cs

Lines changed: 10 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/ai/Azure.AI.VoiceLive/src/VoiceLiveSession.Commands.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ public virtual async Task AddItemAsync(ConversationItemWithReference item, strin
267267
var itemCreateData = new
268268
{
269269
type = "conversation.item.create",
270-
item = item,
270+
item = item.ToRequestContent(),
271271
previous_item_id = previousItemId
272272
};
273273

sdk/ai/Azure.AI.VoiceLive/tspCodeModel.json

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14203,11 +14203,32 @@
1420314203
{
1420414204
"$id": "1047",
1420514205
"kind": "property",
14206+
"name": "name",
14207+
"serializedName": "name",
14208+
"doc": "function name",
14209+
"type": {
14210+
"$id": "1048",
14211+
"kind": "string",
14212+
"name": "string",
14213+
"crossLanguageDefinitionId": "TypeSpec.string",
14214+
"decorators": []
14215+
},
14216+
"optional": false,
14217+
"readOnly": false,
14218+
"discriminator": false,
14219+
"flatten": false,
14220+
"decorators": [],
14221+
"crossLanguageDefinitionId": "VoiceLive.ServerEventResponseFunctionCallArgumentsDone.name",
14222+
"serializationOptions": {}
14223+
},
14224+
{
14225+
"$id": "1049",
14226+
"kind": "property",
1420614227
"name": "arguments",
1420714228
"serializedName": "arguments",
1420814229
"doc": "The final arguments as a JSON string.",
1420914230
"type": {
14210-
"$id": "1048",
14231+
"$id": "1050",
1421114232
"kind": "string",
1421214233
"name": "string",
1421314234
"crossLanguageDefinitionId": "TypeSpec.string",
@@ -14227,13 +14248,13 @@
1422714248
},
1422814249
"properties": [
1422914250
{
14230-
"$id": "1049",
14251+
"$id": "1051",
1423114252
"kind": "property",
1423214253
"name": "type",
1423314254
"serializedName": "type",
1423414255
"doc": "The event type, must be 'session.avatar.connecting'.",
1423514256
"type": {
14236-
"$id": "1050",
14257+
"$id": "1052",
1423714258
"kind": "enumvalue",
1423814259
"name": "session_avatar_connecting",
1423914260
"value": "session.avatar.connecting",
@@ -14258,13 +14279,13 @@
1425814279
}
1425914280
},
1426014281
{
14261-
"$id": "1051",
14282+
"$id": "1053",
1426214283
"kind": "property",
1426314284
"name": "server_sdp",
1426414285
"serializedName": "server_sdp",
1426514286
"doc": "The server's SDP answer for the avatar connection.",
1426614287
"type": {
14267-
"$id": "1052",
14288+
"$id": "1054",
1426814289
"kind": "string",
1426914290
"name": "string",
1427014291
"crossLanguageDefinitionId": "TypeSpec.string",
@@ -14443,27 +14464,27 @@
1444314464
],
1444414465
"clients": [
1444514466
{
14446-
"$id": "1053",
14467+
"$id": "1055",
1444714468
"kind": "client",
1444814469
"name": "VoiceLiveClient",
1444914470
"namespace": "Azure.AI.VoiceLive",
1445014471
"methods": [
1445114472
{
14452-
"$id": "1054",
14473+
"$id": "1056",
1445314474
"kind": "basic",
1445414475
"name": "force_models",
1445514476
"accessibility": "internal",
1445614477
"apiVersions": [
1445714478
"2025-05-01-preview"
1445814479
],
1445914480
"operation": {
14460-
"$id": "1055",
14481+
"$id": "1057",
1446114482
"name": "force_models",
1446214483
"resourceName": "VoiceLive",
1446314484
"accessibility": "internal",
1446414485
"parameters": [
1446514486
{
14466-
"$id": "1056",
14487+
"$id": "1058",
1446714488
"name": "contentType",
1446814489
"nameInRequest": "Content-Type",
1446914490
"doc": "Body parameter's content type. Known values are application/json",
@@ -14481,11 +14502,11 @@
1448114502
"skipUrlEncoding": false
1448214503
},
1448314504
{
14484-
"$id": "1057",
14505+
"$id": "1059",
1448514506
"name": "accept",
1448614507
"nameInRequest": "Accept",
1448714508
"type": {
14488-
"$id": "1058",
14509+
"$id": "1060",
1448914510
"kind": "string",
1449014511
"name": "string",
1449114512
"crossLanguageDefinitionId": "TypeSpec.string",
@@ -14502,7 +14523,7 @@
1450214523
"skipUrlEncoding": false
1450314524
},
1450414525
{
14505-
"$id": "1059",
14526+
"$id": "1061",
1450614527
"name": "forceModelsRequest",
1450714528
"nameInRequest": "forceModelsRequest",
1450814529
"type": {
@@ -14574,7 +14595,7 @@
1457414595
},
1457514596
"parameters": [
1457614597
{
14577-
"$id": "1060",
14598+
"$id": "1062",
1457814599
"name": "event",
1457914600
"nameInRequest": "event",
1458014601
"type": {
@@ -14591,7 +14612,7 @@
1459114612
"skipUrlEncoding": false
1459214613
},
1459314614
{
14594-
"$id": "1061",
14615+
"$id": "1063",
1459514616
"name": "contentType",
1459614617
"nameInRequest": "contentType",
1459714618
"doc": "Body parameter's content type. Known values are application/json",
@@ -14609,11 +14630,11 @@
1460914630
"skipUrlEncoding": false
1461014631
},
1461114632
{
14612-
"$id": "1062",
14633+
"$id": "1064",
1461314634
"name": "accept",
1461414635
"nameInRequest": "accept",
1461514636
"type": {
14616-
"$ref": "1058"
14637+
"$ref": "1060"
1461714638
},
1461814639
"location": "Header",
1461914640
"isApiVersion": false,
@@ -14639,12 +14660,12 @@
1463914660
],
1464014661
"parameters": [
1464114662
{
14642-
"$id": "1063",
14663+
"$id": "1065",
1464314664
"name": "endpoint",
1464414665
"nameInRequest": "endpoint",
1464514666
"doc": "Azure AI VoiceLive endpoint.",
1464614667
"type": {
14647-
"$id": "1064",
14668+
"$id": "1066",
1464814669
"kind": "url",
1464914670
"name": "endpoint",
1465014671
"crossLanguageDefinitionId": "TypeSpec.url"

0 commit comments

Comments
 (0)