如何在对话流中区分为语音响应的缩写



我已经将我的dialogflow代理与Google Assistant集成在一起。有一个受欢迎的意图,会要求您选择任何选项

Choose any of the sports 1. NBA 2. NHL 3. FIH

它用单个单词(作为缩写(读取响应。但是当我从 webhook 生成相同的响应时,它不是用单个单词阅读响应(或不将响应视为缩写(而是一起阅读。我怎样才能做到这一点?我在回复中遗漏了什么吗?

您可能希望确保在响应中发回 SSML,而不是发回文本并让它将其转换为语音,并使用<say-as>标记专门标记缩写并告诉它将内容解释为字符。

因此,您可以将其发回如下:

<speak>
Are you interested in learning more about 
the <say-as interpret-as="characters">NBA</say-as>,
the <say-as interpret-as="characters">NHL</say-as>
or the <say-as interpret-as="characters">FIH</say-as>?
</speak>

有和没有SSML的发音差异很小,这是严重的问题。我坚持说话/为一切说话。还有一个我喜欢的唯一数字和一个测试钩子,无论是否具有语音"计数",因此有一种方法可以测试事物。也是一个钩子,因此触发了"请重复"的意图:

重点是用 sayUsual 来表示一切普通的事情。

// Mostly SSML start char kit as globals
const startSp = "<speak>", endSp = "</speak>";
// Handle "Can you repeat that ?" well
var vfSpokenByMe = "";
// VF near globals what was said, etc
var repeatPossible = {}; repeatPossible.vf = ""; repeatPossible.n = 0;
// An answer from this app to the human in text
function absorbMachineVf( intentNumber, aKind, aStatement )
{
// Numbers reserved for 'repeats'
if( intentNumber > 9000 ) { return; }
// Machine to say this, a number for intents too
repeatPossible.vf = aStatement; repeatPossible.n = intentNumber;
}

// Usual way to say a thing
function sayUsual( n, speechAgent, somethingToSay )
{
// Work with an answer of any sort
absorbMachineVf( n, 'usual', somethingToSay );
// Sometimes we are just pretending, so
if( !testingNow )
{ speechAgent.add( startSp + somethingToSay + endSp ); }
// Make what we said as an answer available 'for sure' to rest of code
vfSpokenByMe = somethingToSay;                            // Even in simulation
}

最新更新