如何减慢 Twilio 的 TwiML“Say”命令以编程方式从 API 进行调用?
How to Slow Down Twilio's TwiML “Say” Command For Programmatically Making Call From the API?
如何减慢 Say 标签内的代码或整个消息内容?
现在默认速度必须设置为 x100 或其他东西。
你一个字也听不懂机器人在说什么。
我用来执行调用的代码:
string accountSid = Configuration.AppSettings("TwilioAccountSID");
string authToken = Configuration.AppSettings("TwilioAuthToken");
TwilioClient.Init(accountSid, authToken);
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
| SecurityProtocolType.Tls11
| SecurityProtocolType.Tls12
| SecurityProtocolType.Ssl3;
char[] charCodeArr = code.ToString().ToCharArray();
string formattedCode = string.Join(" ", charCodeArr);
var message = CallResource.Create
(
twiml: new Twilio.Types.Twiml("<Response><Say>Your code is " + formattedCode + "</Say></Response>"),
from: new Twilio.Types.PhoneNumber(Configuration.AppSettings("TwilioPhoneNumber")),
to: new Twilio.Types.PhoneNumber(phone)
);
我可以在文本中的每个字符后插入一堆逗号,但必须有一种干净的方式来做到这一点。
我无法放慢声音,但我可以在每个数字之间暂停机器人,让用户有时间输入或写下它。我在每个 <Say>Digit</Say>
.
之间插入了 <Pause Length="2"/>
标签
public static bool VoiceMessage(string phone, int code)
{
try
{
string accountSid = Configuration.AppSettings("TwilioAccountSID");
string authToken = Configuration.AppSettings("TwilioAuthToken");
TwilioClient.Init(accountSid, authToken);
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
| SecurityProtocolType.Tls11
| SecurityProtocolType.Tls12
| SecurityProtocolType.Ssl3;
char[] charCodeArr = code.ToString().ToCharArray();
List<string> charCodeList = new List<string>();
foreach (var c in charCodeArr)
{
string charCode = "<Say>" + c + "</Say><Pause length=\"2\"/>";
charCodeList.Add(charCode);
}
string formattedCode = string.Join("", charCodeList);
var message = CallResource.Create(
twiml: new Twilio.Types.Twiml("<Response><Say>Please write down your login code</Say>" + formattedCode + "</Response>"),
from: new Twilio.Types.PhoneNumber(Configuration.AppSettings("TwilioPhoneNumber")),
to: new Twilio.Types.PhoneNumber(phone)
);
return true;
}
catch (Exception exception)
{
Log.Exception(exception);
return false;
}
}
此处为 Twilio 开发人员布道师。
有几种方法可以放慢语速。
你贴的选项肯定是一种方式。使用单独的 <Say>
和 <Pause>
元素将在字符或句子之间放置停顿。
您也可以在 <Say>
元素中暂停内容。 Punctuation will be used as natural pause,这样您就可以用句点分隔数字,以便更慢地读出它们。
为了更高级的使用,AWS Polly voices support the use of SSML. To slow the rate of speech, you can use the prosody element 加上 rate
属性。例如:
<Say>
This is normal speed and <prosody rate="slow">this is much slower</prosody>
</Say>
对于您的情况,您可以执行以下操作:
char[] charCodeArr = code.ToString().ToCharArray();
string formattedCode = "<prosody rate='slow'>" + string.Join(" ", charCodeArr) + "</prosody>";
var message = CallResource.Create
(
twiml: new Twilio.Types.Twiml("<Response><Say voice='Polly.Matthew'>Your code is " + formattedCode + "</Say></Response>"),
from: new Twilio.Types.PhoneNumber(Configuration.AppSettings("TwilioPhoneNumber")),
to: new Twilio.Types.PhoneNumber(phone)
);
如何减慢 Say 标签内的代码或整个消息内容? 现在默认速度必须设置为 x100 或其他东西。
你一个字也听不懂机器人在说什么。
我用来执行调用的代码:
string accountSid = Configuration.AppSettings("TwilioAccountSID");
string authToken = Configuration.AppSettings("TwilioAuthToken");
TwilioClient.Init(accountSid, authToken);
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
| SecurityProtocolType.Tls11
| SecurityProtocolType.Tls12
| SecurityProtocolType.Ssl3;
char[] charCodeArr = code.ToString().ToCharArray();
string formattedCode = string.Join(" ", charCodeArr);
var message = CallResource.Create
(
twiml: new Twilio.Types.Twiml("<Response><Say>Your code is " + formattedCode + "</Say></Response>"),
from: new Twilio.Types.PhoneNumber(Configuration.AppSettings("TwilioPhoneNumber")),
to: new Twilio.Types.PhoneNumber(phone)
);
我可以在文本中的每个字符后插入一堆逗号,但必须有一种干净的方式来做到这一点。
我无法放慢声音,但我可以在每个数字之间暂停机器人,让用户有时间输入或写下它。我在每个 <Say>Digit</Say>
.
<Pause Length="2"/>
标签
public static bool VoiceMessage(string phone, int code)
{
try
{
string accountSid = Configuration.AppSettings("TwilioAccountSID");
string authToken = Configuration.AppSettings("TwilioAuthToken");
TwilioClient.Init(accountSid, authToken);
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
| SecurityProtocolType.Tls11
| SecurityProtocolType.Tls12
| SecurityProtocolType.Ssl3;
char[] charCodeArr = code.ToString().ToCharArray();
List<string> charCodeList = new List<string>();
foreach (var c in charCodeArr)
{
string charCode = "<Say>" + c + "</Say><Pause length=\"2\"/>";
charCodeList.Add(charCode);
}
string formattedCode = string.Join("", charCodeList);
var message = CallResource.Create(
twiml: new Twilio.Types.Twiml("<Response><Say>Please write down your login code</Say>" + formattedCode + "</Response>"),
from: new Twilio.Types.PhoneNumber(Configuration.AppSettings("TwilioPhoneNumber")),
to: new Twilio.Types.PhoneNumber(phone)
);
return true;
}
catch (Exception exception)
{
Log.Exception(exception);
return false;
}
}
此处为 Twilio 开发人员布道师。
有几种方法可以放慢语速。
你贴的选项肯定是一种方式。使用单独的 <Say>
和 <Pause>
元素将在字符或句子之间放置停顿。
您也可以在 <Say>
元素中暂停内容。 Punctuation will be used as natural pause,这样您就可以用句点分隔数字,以便更慢地读出它们。
为了更高级的使用,AWS Polly voices support the use of SSML. To slow the rate of speech, you can use the prosody element 加上 rate
属性。例如:
<Say>
This is normal speed and <prosody rate="slow">this is much slower</prosody>
</Say>
对于您的情况,您可以执行以下操作:
char[] charCodeArr = code.ToString().ToCharArray();
string formattedCode = "<prosody rate='slow'>" + string.Join(" ", charCodeArr) + "</prosody>";
var message = CallResource.Create
(
twiml: new Twilio.Types.Twiml("<Response><Say voice='Polly.Matthew'>Your code is " + formattedCode + "</Say></Response>"),
from: new Twilio.Types.PhoneNumber(Configuration.AppSettings("TwilioPhoneNumber")),
to: new Twilio.Types.PhoneNumber(phone)
);