How to create my first vocal service in PHP

Last modified by Stéphane Laurière on 2015/10/20 17:10

you must complete the callback file. By default this file is called incoming.php, it is automatically created at the creation of your project. So you may change the name..but everything is ready and pre-configured at the installation of the project.

You can see this file in the configuration tab of your self-care

Callbackfile.png

A basic example of vocal service can be described as follow:

<?php
// Load required configuration
require_once ("passwords.php");

// Answer the call
$call->Answer();

// Say something in English
$call->Say("Hello World, can you hear me in your phone !", $api_login, $api_password, "En");

// Say something in English and wait for a DTMF (key pressed)
$menu = $call->Ask("Please press a digit on your phone", $api_login, $api_password, "En");

// $menu is an array including a code field and a result field (see SDK for details)
$dtmf = $menu['result'];
echo $dtmf;

$call->Say("I know that you pressed the key: $dtmf", $api_login, $api_password, "En");

// Say something in English and use voice recognition (powered by google)
// En = English used for the TTS, en = Englisg used for the voice recognition
$ret = $call->AskWithSpeechReco("Say something I will try to understand what you mean", $api_login, $api_password, 'en', 'En');

// All the messages printed using echo or print_r will be displayed in the log tab of your self-care (section incoming calls)
print_r($ret);
// $ret is an array with 2 fields:
//  'detected_speech' = text said by the user
//  'confidence' = a float between 0 (no confidence) an 1 (strong confidence)
if ($ret['detected_speech'])
   $call->Say("You said : ".$ret['detected_speech'], $api_login, $api_password, "En");

// Hangup the line
$call->Hangup();
?>

You may test your service using a VoIP (or WebRTC) client registered on the <your_emerginov> domain. Just call your project name in capital letters, you shall be connected to your PHP kiosk!

If you need a routable PSTN number, you shall contact your administrator.

Tags:
Created by Stéphane Laurière on 2014/04/08 17:30

Partners

Orange

VOICES

EU - FP7

OW2

© Emerginov
Site maintained by OW2