想要嵌套"说"集合中的指令,但我想在"上使用诸如.Emphasis、.Break和.Prosody之类的修饰符;说"说明书在C#中似乎没有办法做到这一点。我想要的TwiML代码如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Gather action="/voice/processmygather" method="GET">
<Say> Hi
<break strength="x-weak" time="100ms"/>
<emphasis level="moderate">Words to emphasize</emphasis>
<p>Words to speak</p>
<prosody pitch="-10%" rate="85%" volume="-6dB">Words to speak</prosody>
<s>Words to speak</s>
<say-as interpret-as="spell-out">Words to speak</say-as>
<sub alias="alias">Words to be substituted</sub>
<w>Words to speak</w>
</Say>
</Gather>
<Say>We didn't receive any input. Goodbye!</Say>
</Response>
在C#中,我可以创建一个";说"动词对象,并将其修改为类似上面的样子,但不能将其排列为嵌套在集合中,这样用户就可以用响应中断发言并继续处理集合。
var response = new VoiceResponse();
var mygather = new Gather(input: bothDtmfAndSpeech,
action: new Uri("/voice/processmygather", UriKind.Relative),
speechModel: Gather.SpeechModelEnum.NumbersAndCommands,
enhanced: true,
hints: hintchoices,
bargeIn: true,
speechTimeout: "auto",
numDigits: 1);
var mysay = new Say("Hi", voice: "Polly.Joanna");
mysay.Break(strength: "x-weak", time: "100ms");
mysay.Emphasis("Words to emphasize", level: "moderate");
mysay.P("Words to speak");
mysay.Phoneme("Words to speak", alphabet: "x-sampa", ph: "pɪˈkɑːn");
mysay.Prosody("Words to speak", pitch: "-10%", rate: "85%", volume: "-6dB");
mysay.SayAs("Words to speak", interpretAs: "spell-out", role: "yyyymmdd");
/* There seems to be no way to do the following command */
response.Append(mygather.mysay);
/* I can only do the following */
response.Append(mysay); // plays the entire say
response.Append(mygather); // only after playing entire say am I able to gather
/* I seem to able to do only the following with limited markup capability */
response.Append(mygather.Say("Here is something I want to say but have little ability to fine tune the say with .Emphasis .Break or .Prosody controls"));
那么,是否可以在集合中用我想要的所有控件标记我的Say(很像上面的顶部代码块(,将其保存到XML文件中,然后将响应对象指向该XML文件,并且仍然能够在我的C#应用程序中捕获用户的语音或数字响应?
决定为子孙后代发布答案,以防其他人遇到类似问题并出现在本页上。
将say对象包含在聚集对象中的正确方法是:
/* include the marked up mysay object within the mygather object */
mygather.Append(mysay);
/* speak the marked up mysay twiML while waiting an answer */
response.Append(mygather);
另一个需要注意的是,如果mysay指定了一个-Neural语音,它将不会播放一些标记的标签,如.Emphasis。
下表显示了标记标记的兼容性:https://docs.aws.amazon.com/polly/latest/dg/supportedtags.html
感谢用户";tychon";(在上面的评论中(谁提供了提示来帮助我找到答案。