sync with upstream
This commit is contained in:
commit
0a956efea7
|
|
@ -213,7 +213,7 @@ public class TwilioVoiceController : TwilioController
|
|||
response = twilio.ReturnInstructions(new List<string>
|
||||
{
|
||||
$"twilio/voice/speeches/{conversationId}/{reply.SpeechFileName}"
|
||||
}, $"twilio/voice/{conversationId}/receive/{nextSeqNum}?states={states}", true);
|
||||
}, $"twilio/voice/{conversationId}/receive/{nextSeqNum}?states={states}", true, hints:reply.Hints);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,5 +7,6 @@ namespace BotSharp.Plugin.Twilio.Models
|
|||
public string Content { get; set; }
|
||||
public string MessageId { get; set; }
|
||||
public string SpeechFileName { get; set; }
|
||||
public string Hints { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,8 +106,27 @@ namespace BotSharp.Plugin.Twilio.Services
|
|||
var data = await completion.GenerateAudioFromTextAsync(reply.Content);
|
||||
var fileName = $"reply_{reply.MessageId}.mp3";
|
||||
fileStorage.SaveSpeechFile(message.ConversationId, fileName, data);
|
||||
|
||||
reply.SpeechFileName = fileName;
|
||||
var phrases = reply.Content.Split(',', StringSplitOptions.RemoveEmptyEntries);
|
||||
int capcity = 100;
|
||||
var hints = new List<string>(capcity);
|
||||
for (int i = phrases.Length - 1; i >= 0; i--)
|
||||
{
|
||||
var words = phrases[i].Split(' ', StringSplitOptions.RemoveEmptyEntries);
|
||||
for (int j = words.Length - 1; j >= 0; j--)
|
||||
{
|
||||
hints.Add(words[j]);
|
||||
if (hints.Count >= capcity)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (hints.Count >= capcity)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
reply.Hints = string.Join(',', hints);
|
||||
reply.Content = null;
|
||||
await sessionManager.SetAssistantReplyAsync(message.ConversationId, message.SeqNumber, reply);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ public class TwilioService
|
|||
return response;
|
||||
}
|
||||
|
||||
public VoiceResponse ReturnInstructions(List<string> speechPaths, string callbackPath, bool actionOnEmptyResult, int timeout = 5)
|
||||
public VoiceResponse ReturnInstructions(List<string> speechPaths, string callbackPath, bool actionOnEmptyResult, int timeout = 3, string hints = null)
|
||||
{
|
||||
var response = new VoiceResponse();
|
||||
var gather = new Gather()
|
||||
|
|
@ -78,10 +78,10 @@ public class TwilioService
|
|||
},
|
||||
Action = new Uri($"{_settings.CallbackHost}/{callbackPath}"),
|
||||
SpeechModel = Gather.SpeechModelEnum.PhoneCall,
|
||||
SpeechTimeout = "auto", // timeout > 0 ? timeout.ToString() : "5",
|
||||
Timeout = timeout > 0 ? timeout : 5,
|
||||
SpeechTimeout = "auto", // timeout > 0 ? timeout.ToString() : "3",
|
||||
Timeout = timeout > 0 ? timeout : 3,
|
||||
ActionOnEmptyResult = actionOnEmptyResult,
|
||||
Hints = "Yes, No, Correct"
|
||||
Hints = hints
|
||||
};
|
||||
|
||||
if (!speechPaths.IsNullOrEmpty())
|
||||
|
|
|
|||
Loading…
Reference in a new issue