Skip to content

Commit 93d752e

Browse files
authored
Merge pull request #1027 from hchen2020/master
GenerateEndingAudio
2 parents 5d8cf06 + 701a8f1 commit 93d752e

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

src/Plugins/BotSharp.Plugin.Twilio/OutboundPhoneCallHandler/Functions/HangupPhoneCallFn.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,16 @@ public async Task<bool> Execute(RoleDialogModel message)
4444
var processUrl = $"{_twilioSetting.CallbackHost}/twilio/voice/hang-up?agent-id={message.CurrentAgentId}&conversation-id={conversationId}";
4545

4646
// Generate initial assistant audio
47-
/*string initAudioFile = null;
48-
if (!string.IsNullOrEmpty(args.ResponseContent))
47+
string initAudioFile = null;
48+
if (!string.IsNullOrEmpty(args.ResponseContent) && _twilioSetting.GenerateEndingAudio)
4949
{
5050
var completion = CompletionProvider.GetAudioSynthesizer(_services);
5151
var data = await completion.GenerateAudioAsync(args.ResponseContent);
5252
initAudioFile = "ending.mp3";
5353
fileStorage.SaveSpeechFile(conversationId, initAudioFile, data);
5454

5555
processUrl += $"&init-audio-file={initAudioFile}";
56-
}*/
56+
}
5757

5858
var call = CallResource.Update(
5959
url: new Uri(processUrl),

src/Plugins/BotSharp.Plugin.Twilio/Services/TwilioService.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,6 @@ public VoiceResponse HangUp(ConversationalVoiceResponse voiceResponse)
145145
response.Play(new Uri(uri));
146146
}
147147
}
148-
else
149-
{
150-
response.Say("Goodbye.");
151-
}
152148

153149
response.Hangup();
154150
return response;

src/Plugins/BotSharp.Plugin.Twilio/Settings/TwilioSetting.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@ public class TwilioSetting
3232
public bool TranscribeEnabled { get; set; } = false;
3333

3434
public bool GenerateReplyAudio { get; set; } = true;
35+
public bool GenerateEndingAudio { get; set; } = true;
3536
}

src/Plugins/BotSharp.Plugin.Twilio/data/agents/6745151e-6d46-4a02-8de4-1c4f21c7da95/functions/util-twilio-hangup_phone_call.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@
88
"reason": {
99
"type": "string",
1010
"description": "The reason why user wants to end the phone call."
11+
},
12+
"response_content": {
13+
"type": "string",
14+
"description": "A response statement said to the user to politely and gratefully ending a conversation before hanging up."
1115
}
1216
},
13-
"required": [ "reason" ]
17+
"required": [ "reason", "response_content" ]
1418
}
1519
}

0 commit comments

Comments
 (0)