Voicexml: <record> submiting truncate audio message

211 Views Asked by At

I am trying to create an answering machine. I am using Nexmo.

I have two numbers : One French Number, and one US Number (California)

When I call my french number, my audio message is saved on my server and i can listen it. But when i call my US Number, I can listen my prompt (here it's ) but the audio message saved is not saved correctly. I don't know why, any idea ?

phone.php

<?php
    // accept both query string and post
    $request = array_merge($_GET, $_POST);
    error_log('got a call from: ' . $request['nexmo_caller_id']);
    // make the XML short tag friendly
    echo '<?xml version="1.0" encoding="UTF-8"?>';
    ?>
    <vxml version = "2.1">
        <form>
            <record name="message" beep="true" maxtime="60s" dtmfterm="true">
                <audio src="./welcome.wav"/>
            </record>
            <catch event="connection.disconnect.hangup">
                <submit next="./recphone.php" enctype="multipart/form-data" method="post"/>
            </catch>
        </form>
    </vxml>

recphone.php

<?php
if(!isset($_FILES['message'])){
    return; //not a post from our script
}

switch($_FILES['message']['error']){
    case UPLOAD_ERR_OK:
        move_uploaded_file($_FILES['message']['tmp_name'], './recordings/' . $_FILES['message']['name']);
        $prompt = 'Thanks, your message has been saved.';
        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>
3

There are 3 best solutions below

0
Guillaume On BEST ANSWER

There is a problem with Nexmo when redirects calls to a VoiceXML document.

I finally decide to use Asterisk to create my IVR.

If someone landed here with the idea of creating its IVR, I wrote a tutorial on my GitHub : https://github.com/guillaumeteillet/ivr-guillaume-teillet

1
Olivier On

Guillaume,

I'm not sure why it's not working, to be honest. When you say it's not saved correctly, what do you mean? Do you have a problem with the content of the audio? The codec? Or something else?

Also, when you do your tests, where do you do it from? E.g. are you calling your French number from France, and the US number from France too? If so, what's happening if calling the US number from the US itself?

Lastly, what kind of US number have you got with Nexmo? Have you checked it has all the requirements for your use case?

1
Jim Rush On

Are the audio volumes different on the two TFNs? Is it possible the platform is thinking audio has stopped because the volume levels drop below the detection threshold?

If the audio truncation is consistent regardless of the length of the message left, I would look towards the platform as having an inconsistent setting.