Skip to content

Commit 742e28b

Browse files
committed
Getting closer
1 parent 700648f commit 742e28b

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
@@ -446,7 +446,7 @@ public virtual async Task AddItemAsync(ConversationItemWithReference item, strin
446446
var itemCreateData = new
447447
{
448448
type = "conversation.item.create",
449-
item = item,
449+
item = item.ToRequestContent(),
450450
previous_item_id = previousItemId
451451
};
452452

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

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14542,11 +14542,32 @@
1454214542
{
1454314543
"$id": "1047",
1454414544
"kind": "property",
14545+
"name": "name",
14546+
"serializedName": "name",
14547+
"doc": "function name",
14548+
"type": {
14549+
"$id": "1048",
14550+
"kind": "string",
14551+
"name": "string",
14552+
"crossLanguageDefinitionId": "TypeSpec.string",
14553+
"decorators": []
14554+
},
14555+
"optional": false,
14556+
"readOnly": false,
14557+
"discriminator": false,
14558+
"flatten": false,
14559+
"decorators": [],
14560+
"crossLanguageDefinitionId": "VoiceLive.ServerEventResponseFunctionCallArgumentsDone.name",
14561+
"serializationOptions": {}
14562+
},
14563+
{
14564+
"$id": "1049",
14565+
"kind": "property",
1454514566
"name": "arguments",
1454614567
"serializedName": "arguments",
1454714568
"doc": "The final arguments as a JSON string.",
1454814569
"type": {
14549-
"$id": "1048",
14570+
"$id": "1050",
1455014571
"kind": "string",
1455114572
"name": "string",
1455214573
"crossLanguageDefinitionId": "TypeSpec.string",
@@ -14566,13 +14587,13 @@
1456614587
},
1456714588
"properties": [
1456814589
{
14569-
"$id": "1049",
14590+
"$id": "1051",
1457014591
"kind": "property",
1457114592
"name": "type",
1457214593
"serializedName": "type",
1457314594
"doc": "The event type, must be 'session.avatar.connecting'.",
1457414595
"type": {
14575-
"$id": "1050",
14596+
"$id": "1052",
1457614597
"kind": "enumvalue",
1457714598
"name": "session_avatar_connecting",
1457814599
"value": "session.avatar.connecting",
@@ -14597,13 +14618,13 @@
1459714618
}
1459814619
},
1459914620
{
14600-
"$id": "1051",
14621+
"$id": "1053",
1460114622
"kind": "property",
1460214623
"name": "server_sdp",
1460314624
"serializedName": "server_sdp",
1460414625
"doc": "The server's SDP answer for the avatar connection.",
1460514626
"type": {
14606-
"$id": "1052",
14627+
"$id": "1054",
1460714628
"kind": "string",
1460814629
"name": "string",
1460914630
"crossLanguageDefinitionId": "TypeSpec.string",
@@ -14782,27 +14803,27 @@
1478214803
],
1478314804
"clients": [
1478414805
{
14785-
"$id": "1053",
14806+
"$id": "1055",
1478614807
"kind": "client",
1478714808
"name": "VoiceLiveClient",
1478814809
"namespace": "Azure.AI.VoiceLive",
1478914810
"methods": [
1479014811
{
14791-
"$id": "1054",
14812+
"$id": "1056",
1479214813
"kind": "basic",
1479314814
"name": "force_models",
1479414815
"accessibility": "internal",
1479514816
"apiVersions": [
1479614817
"2025-05-01-preview"
1479714818
],
1479814819
"operation": {
14799-
"$id": "1055",
14820+
"$id": "1057",
1480014821
"name": "force_models",
1480114822
"resourceName": "VoiceLive",
1480214823
"accessibility": "internal",
1480314824
"parameters": [
1480414825
{
14805-
"$id": "1056",
14826+
"$id": "1058",
1480614827
"name": "contentType",
1480714828
"nameInRequest": "Content-Type",
1480814829
"doc": "Body parameter's content type. Known values are application/json",
@@ -14820,11 +14841,11 @@
1482014841
"skipUrlEncoding": false
1482114842
},
1482214843
{
14823-
"$id": "1057",
14844+
"$id": "1059",
1482414845
"name": "accept",
1482514846
"nameInRequest": "Accept",
1482614847
"type": {
14827-
"$id": "1058",
14848+
"$id": "1060",
1482814849
"kind": "string",
1482914850
"name": "string",
1483014851
"crossLanguageDefinitionId": "TypeSpec.string",
@@ -14841,7 +14862,7 @@
1484114862
"skipUrlEncoding": false
1484214863
},
1484314864
{
14844-
"$id": "1059",
14865+
"$id": "1061",
1484514866
"name": "forceModelsRequest",
1484614867
"nameInRequest": "forceModelsRequest",
1484714868
"type": {
@@ -14913,7 +14934,7 @@
1491314934
},
1491414935
"parameters": [
1491514936
{
14916-
"$id": "1060",
14937+
"$id": "1062",
1491714938
"name": "event",
1491814939
"nameInRequest": "event",
1491914940
"type": {
@@ -14930,7 +14951,7 @@
1493014951
"skipUrlEncoding": false
1493114952
},
1493214953
{
14933-
"$id": "1061",
14954+
"$id": "1063",
1493414955
"name": "contentType",
1493514956
"nameInRequest": "contentType",
1493614957
"doc": "Body parameter's content type. Known values are application/json",
@@ -14948,11 +14969,11 @@
1494814969
"skipUrlEncoding": false
1494914970
},
1495014971
{
14951-
"$id": "1062",
14972+
"$id": "1064",
1495214973
"name": "accept",
1495314974
"nameInRequest": "accept",
1495414975
"type": {
14955-
"$ref": "1058"
14976+
"$ref": "1060"
1495614977
},
1495714978
"location": "Header",
1495814979
"isApiVersion": false,
@@ -14978,12 +14999,12 @@
1497814999
],
1497915000
"parameters": [
1498015001
{
14981-
"$id": "1063",
15002+
"$id": "1065",
1498215003
"name": "endpoint",
1498315004
"nameInRequest": "endpoint",
1498415005
"doc": "Azure AI VoiceLive endpoint.",
1498515006
"type": {
14986-
"$id": "1064",
15007+
"$id": "1066",
1498715008
"kind": "url",
1498815009
"name": "endpoint",
1498915010
"crossLanguageDefinitionId": "TypeSpec.url"

0 commit comments

Comments
 (0)