【问题标题】:VoiceXML - how to submit record file and text input togetherVoiceXML - 如何一起提交记录文件和文本输入
【发布时间】:2016-07-18 06:51:12
【问题描述】:

我正在尝试获取来电者的数字键和记录文件。 录音文件也会有哔声(dtmf)。

现在,我只能记录提示+键入,但不能在voice.php中输入“w”文本字符串。

在示例 voice.xml 文件中,如果我删除“字段标签”,那么它会正常工作,因为它将 wav 文件保存到服务器中。

有谁知道同时提交记录文件和文本输入是否可行?如果可行,如何修改 vxml 文件?应该使用什么类型的enctype?

如果使用 Nexmo 不可行,是否有其他服务提供商可以支持用户构建这样的场景?

voice.xml 代码

<?xml version="1.0" encoding="UTF-8"?>
<vxml version = "2.1">
    <form id="top">
        <property name="inputmodes" value="dtmf"/>
        <property name="interdigittimeout" value="2s"/>
        <property name="timeout" value="4s"/>
        <record name="message" beep="true" maxtime="60s" dtmfterm="true">
                <field name="w" type="digits?maxlength=6">
                    <prompt bargein="true">
                      Please enter 6 digit number.
                    </prompt>
                </field>
        </record>
        <block>
            <submit next="./voice.php" enctype="multipart/form-data" method="post"/>
        </block>
    </form>
</vxml>    

voice.php 代码

<?php

if(!isset($_FILES['message'])){
    $mfile = fopen("./log/request.log", "a") or die("unable to open file!");
    fwrite($mfile, date('m/d/Y h:i:s a', time())." POST:".print_r($_POST, true)."\n");
    fwrite($mfile, date('m/d/Y h:i:s a', time())." GET:".print_r($_GET, true)."\n");
    fclose($mfile);
    return;
}

switch($_FILES['message']['error']){
    case UPLOAD_ERR_OK:
        move_uploaded_file($_FILES['message']['tmp_name'], './log/' . $_FILES['message']['name']);
        $mfile = fopen("./log/request.log", "a") or die("unable to open file!");
        fwrite($mfile, date('m/d/Y h:i:s a', time())." POST:".print_r($_POST, true)."\n");
        fwrite($mfile, date('m/d/Y h:i:s a', time())." GET:".print_r($_GET, true)."\n");
        fclose($mfile);
        $prompt = 'Thanks.';
        break;
    default:
        $prompt = 'Sorry, we could not save your message.';
}
echo '<?xml version="1.0" encoding="UTF-8"?>';
?>
<vxml version="2.1">
    <form>
        <block>
            <prompt><?php echo $prompt ?></prompt>
        </block>
    </form>
</vxml>

【问题讨论】:

    标签: php vxml vonage


    【解决方案1】:

    VoiceXML 不允许同时进行识别和录音。输入将是一个或另一个。您可以执行录音并对录音进行一些音频分析,尽管它可能会变得混乱(您需要进行过滤/信号分析以及一些去抖逻辑,以防止混乱的音频认为单音按下是多个)。

    某些平台允许独立于 VoiceXML 的通话录音。但是,大多数用于语音调整和诊断。因此,它们不是为在通话期间访问而设计的。

    【讨论】:

    • 非常感谢您的回答。我希望这是可行的,并试图与 Nexmo 进行验证,但他们没有证实这一点。正如你所说,我正在考虑使用 wav 文件进行音压识别,这将非常混乱。我将等待几天,然后接受这个作为答案。
    猜你喜欢
    • 1970-01-01
    • 2017-02-24
    • 2018-09-15
    • 1970-01-01
    • 1970-01-01
    • 2012-02-20
    • 2013-04-29
    • 2012-12-17
    • 1970-01-01
    相关资源
    最近更新 更多