将Twilio文本放慢到语音播放中

时间:2018-11-20 18:21:24

标签: twilio twilio-api

我正在尝试使用SSMLProsody函数来减慢人物姓名以及电话号码的播放速度。我已使用空间和周期方法来显示进度,但我希望获得更多控制。我看到SSMLProsody方法有一个“比率”,我认为可以解决问题,但我无法使其工作。如果有人可以帮助我,我将不胜感激。我的代码示例:

var gather = new Gather(allowVoiceResponse ? new List<Gather.InputEnum>(new[] {Gather.InputEnum.Speech, Gather.InputEnum.Dtmf}) : new List<Gather.InputEnum>(new[] { Gather.InputEnum.Dtmf }),
                numDigits: 1,
                hints: "connect me, connect me now, connect",
                timeout: CallLoopTimeout,
                speechTimeout: "auto",
                action: new Uri($"{NotificationConfigurationManager.Configuration.TwilioVoiceApiAddress}ConnectVisitorCallback?{queryParams.GenerateQueryString()}"),
                method: "POST");

if (lowSpeechConfidence)
{
     gather.Play(new Uri($"{NotificationConfigurationManager.Configuration.TwilioVoiceApiAddress}GetSoundClip?siteId={siteId}&index=3"));
}
else
{
     var sayName = new Say(voice: Say.VoiceEnum.Man).SsmlProsody(queryParams.SpacedName, rate: "30%");
     var sayPhone = new Say(voice: Say.VoiceEnum.Man).SsmlProsody(queryParams.SpacedPhoneNumber, rate: "30%");
     gather.Play(new Uri($"{NotificationConfigurationManager.Configuration.TwilioVoiceApiAddress}GetSoundClip?siteId={siteId}&index=1"))
                    .Append(sayName)
                    .Play(new Uri($"{NotificationConfigurationManager.Configuration.TwilioVoiceApiAddress}GetSoundClip?siteId={siteId}&index=2"))
                    .Append(sayPhone);
 }

1 个答案:

答案 0 :(得分:0)

这里是Twilio开发人员的传播者。

仅在使用Amazon's Polly voices时支持<Prosody>和其他SSML命令。

那么你在哪里:

var sayName = new Say(voice: Say.VoiceEnum.Man).SsmlProsody(queryParams.SpacedName, rate: "30%");

您将需要类似的东西

var sayName = new Say(voice: Say.VoiceEnum.PollyJoanna).SsmlProsody(queryParams.SpacedName, rate: "30%");

您还可以在Twilio控制台中设置默认语音。