GenerateEndingAudio

This commit is contained in:
Haiping Chen 2025-04-22 17:00:14 -05:00
parent 5d8cf0638e
commit 701a8f191b
4 changed files with 9 additions and 8 deletions

View file

@ -44,8 +44,8 @@ public class HangupPhoneCallFn : IFunctionCallback
var processUrl = $"{_twilioSetting.CallbackHost}/twilio/voice/hang-up?agent-id={message.CurrentAgentId}&conversation-id={conversationId}";
// Generate initial assistant audio
/*string initAudioFile = null;
if (!string.IsNullOrEmpty(args.ResponseContent))
string initAudioFile = null;
if (!string.IsNullOrEmpty(args.ResponseContent) && _twilioSetting.GenerateEndingAudio)
{
var completion = CompletionProvider.GetAudioSynthesizer(_services);
var data = await completion.GenerateAudioAsync(args.ResponseContent);
@ -53,7 +53,7 @@ public class HangupPhoneCallFn : IFunctionCallback
fileStorage.SaveSpeechFile(conversationId, initAudioFile, data);
processUrl += $"&init-audio-file={initAudioFile}";
}*/
}
var call = CallResource.Update(
url: new Uri(processUrl),

View file

@ -145,10 +145,6 @@ public class TwilioService
response.Play(new Uri(uri));
}
}
else
{
response.Say("Goodbye.");
}
response.Hangup();
return response;

View file

@ -32,4 +32,5 @@ public class TwilioSetting
public bool TranscribeEnabled { get; set; } = false;
public bool GenerateReplyAudio { get; set; } = true;
public bool GenerateEndingAudio { get; set; } = true;
}

View file

@ -8,8 +8,12 @@
"reason": {
"type": "string",
"description": "The reason why user wants to end the phone call."
},
"response_content": {
"type": "string",
"description": "A response statement said to the user to politely and gratefully ending a conversation before hanging up."
}
},
"required": [ "reason" ]
"required": [ "reason", "response_content" ]
}
}