VoiceXML和TwiML/PlivoXML有什么区别?

Rya*_*yan 3 xml voicexml twilio tropo nexmo

我的任务是研究这两种实现之间的差异,以便更好地理解两者在开发难度和功能集方面的差异,但我没有发现两者之间有任何明确和简洁的比较.

Tim*_*tle 8

我想你要问的是VoiceXML,TwiML和PlivoXML之间的区别.Tropo和Nexmo都支持VoiceXML,因此这是XML格式(和相关平台)的比较,而不是特定供应商.我添加了PlivoXML,因为它与TiwML类似,但是很独特.免责声明:我为Nexmo工作.

所有这三个都描述了在电话呼叫期间发生的事情 - 机器如何与呼叫者进行交互.基本上是用于电话呼叫的HTML,允许您向用户显示信息(播放音频,读取文本)或从用户获取信息(录制音频,识别语音,按数字).

可移植性

VoiceXML是行业标准,与HTML一样,它由W3C管理.TwiML和PlivoXML都是专有的.这意味着VoiceXML应用程序不依赖于特定供应商.

输入

这三个都支持录制音频或捕获DTMF(按键).VoiceXML支持语法,允许您识别语音,并调整该识别引擎.TwiML和PlivoXML没有这种支持.

TwiML示例(期待DTMF):

<Response>
    <Gather action="process.php">
        <Say>Press a few digits.</Say>
    </Gather>
</Response>
Run Code Online (Sandbox Code Playgroud)

VoiceXML示例(期待DTMF或识别):

<vxml version = "2.1">
    <form>
        <field name="department">
            <prompt>Press 1 or say sales, press 2 or say support.</prompt>
            <grammar xml:lang="en-US" root = "TOPLEVEL" mode="voice" >
                <rule id="TOPLEVEL" scope="public">
                    <one-of>
                        <item> sales </item>
                        <item> support </item>
                    </one-of>
                </rule>
            </grammar>
            <grammar xml:lang="en-US" root = "TOPLEVEL" mode="dtmf" >
                <rule id="TOPLEVEL" scope="public">
                    <one-of>
                        <item> 1 <tag> out.department="sales"; </tag> </item>
                        <item> 2 <tag> out.department="support"; </tag> </item>
                    </one-of>
                </rule>
            </grammar>
        </field>
        <block>
            <submit next="../php/form.php" method="post"/>
        </block>
    </form>
</vxml>
Run Code Online (Sandbox Code Playgroud)

产量

这三个都支持文本到语音和播放音频(由链接引用).Plivo还允许您使用API​​播放正在进行的呼叫的音频,但这不在PlivoXML的上下文中.

TwiML示例:

<Response>
    <Say>Hello From TwiML</Say>
</Response>
Run Code Online (Sandbox Code Playgroud)

VoiceXML示例:

<vxml version="2.1">
    <form>
        <block>
            <prompt>Hello from VXML!</prompt>
        </block>
    </form>
</vxml>
Run Code Online (Sandbox Code Playgroud)

变量和状态

TwiML和PlivoXML允许您像浏览器一样跟踪某个会话; 但是,VoiceXML有一个更有用的状态概念,允许您跨多个请求共享变量.

TwiML或PlivoXML文档一次只能真正收集一件事从用户获取数字或记录实际上类似于具有单个元素的表单帖子.

VoiceXML表单不仅限于单个输入,还包含多个识别语音,DTMF印刷,录音的字段.VoiceXML还允许在同一文档中将数据播放/读回给用户,因为它只是一个变量.事实上,单个VoiceXML文档可以有多个表单,用户可以在这些表单之间导航.

VoiceXML示例:

<form id="welcome">
    <field name="customer_type">
        <prompt>Say 'new' or press 1 if you're a new  customer, press 2 or say 'existing' if you have an account.</prompt>
        <grammar xml:lang="en-US" root = "TOPLEVEL" mode="voice" >
            ...
        </grammar>
        <grammar xml:lang="en-US" root = "TOPLEVEL" mode="dtmf" >
            ...
        </grammar>
    </field>
    <filled>
        <prompt cond="customer_type=='new'">
            Thanks for contacting us.
        </prompt>
        <prompt cond="customer_type=='existing'">
            Thanks for being a loyal customer.
        </prompt>
        <goto expr="'#' + customer_type" />
    </filled>
</form>
Run Code Online (Sandbox Code Playgroud)

会议和队列

TwiML和PlivoXML支持在XML文档中添加对会议的调用.TwiML还支持从TwiML直接获得队列的概念(并添加对它的调用)(PlivoXML没有该队列支持).VoiceXML在VXML文档中没有会议或排队的概念(但是,API可以提供外部机制来一起召集多个活动呼叫).

_TwiML示例:

<Response>
    <Dial>
        <Conference>Room 1234</Conference>
    </Dial>
</Response>
Run Code Online (Sandbox Code Playgroud)

转让

这三个人都支持在正在进行的通话中添加第二条腿.VoiceXML允许您使用传输的输出来指示文档的其余部分.

TwiML示例:

<Response>
    <Dial timeout="10" record="true">415-123-4567</Dial>
</Response>
Run Code Online (Sandbox Code Playgroud)

VoiceXML示例:

<vxml version = "2.1">
    <form>
        <transfer name="result" dest="tel:+14158058810" bridge="true">
            <prompt>Please wait while we transfer you.</prompt>
            <grammar xml:lang="en-US" root = "TOPLEVEL" mode="voice">
                <rule id="TOPLEVEL" scope="public">
                    <one-of>
                        <item> disconnect </item>
                    </one-of>
                </rule>
            </grammar>
        </transfer>
        <filled>
            <if cond="result == 'busy'">
                <prompt>Sorry, they're busy.</prompt>
            <elseif cond="result == 'noanswer'" />
                <prompt>Sorry, they didn't answer.</prompt>
            <else />
                <prompt>You spoke for <value expr="result$.duration" /> seconds.</prompt>
            </if>

            <if cond="result$.inputmode == 'voice'">
                You ended the call by saying, <value expr="result$.utterance" />.
            </if>
        </filled>
        <block>
            Thanks for using the transfer element.
        </block>
    </form>
</vxml>
Run Code Online (Sandbox Code Playgroud)

可扩展性:所有这三个允许调用遵循一些链接到另一个VoiceXML/TwiML/PlivoXML文档的概念.但是,VoiceXML具有子对话的概念,其中控制被转移到另一个VoiceXML应用程序,并且返回值被传递回调用应用程序.这可以允许与通用外部服务的集成(或开发).

VoiceXML示例:

<form id="billing_adjustment">
    <var name="account_number"/>
    <var name="home_phone"/>
    <subdialog name="accountinfo" src="acct_info.vxml#basic">
        <filled>
            <!-- Note the variable defined by "accountinfo" is
            returned as an ECMAScript object and it contains two
            properties defined by the variables specified in the
            "return" element of the subdialog. -->

            <assign name="account_number" expr="accountinfo.acctnum"/>
            <assign name="home_phone" expr="accountinfo.acctphone"/>
        </filled>
    </subdialog>
    ....
</form>
Run Code Online (Sandbox Code Playgroud)

基于/复制Twilio的Docs,Nexmo的VXML快速入门W3C的VXML文档的示例.