gpt4 book ai didi

php - VoiceXML - 如何同时提交录音文件和文本输入

转载 作者:搜寻专家 更新时间:2023-10-31 21:24:55 25 4
gpt4 key购买 nike

我正在尝试获取来电者输入的号码和记录文件。录制文件也会有哔声(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>

最佳答案

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

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

关于php - VoiceXML - 如何同时提交录音文件和文本输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38430218/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com