phpvxmlvonage

VoiceXML - how to submit record file and text input together


I am trying to get caller's key in numbers and record file. Record file will have beep sounds(dtmf) as well.

Right now, I am only able to record prompt + keyin, but not getting input "w" text string in voice.php.

In the sample voice.xml file, if I remove "field tag" then it's working as it will save wav file into server.

Does anyone know if it's even doable submitting record file and text input together? If doable, how can I modify vxml file? and what type of enctype should be used?

If it's not doable with Nexmo, is there any other service provider who can support users to build scenarios like this?

voice.xml code

<?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 code

<?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>

Solution

  • VoiceXML doesn't allow for a recognition and a recording to be done concurrently. An input will either be one or the other. You could perform a recording and do some audio analysis on the recording, though it could get messy (you'll need to do filter/signal analysis along with some debounce logic to prevent messy audio from thinking a single tone press is multiple).

    Some platforms, allow for call recording independent of VoiceXML. However, most are for speech tuning and diagnostics. Therefore, they aren't designed to be accessed during the call.