Created
August 13, 2010 13:42
-
-
Save mheadd/522913 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"result": { | |
"actions": { | |
"attempts": 1, | |
"confidence": 51, | |
"disposition": "SUCCESS", | |
"interpretation": "7148745213", | |
"name": "phone", | |
"utterance": "Hugh Jazz", | |
"value": "7148745213", | |
"xml": "<?xml version=\"1.0\"?>\r\n<result grammar=\"[email protected]\">\r\n <interpretation grammar=\"[email protected]\" confidence=\"51\">\r\n \r\n <input mode=\"speech\">Hugh Jazz<\/input>\r\n <\/interpretation>\r\n<\/result>\r\n" | |
}, | |
"callId": "7a6c80d2197102e1691bc7f8d12b0a66", | |
"complete": true, | |
"error": null, | |
"sequence": 1, | |
"sessionDuration": 11, | |
"sessionId": "02a252f059fc07155158102e794bde60", | |
"state": "ANSWERED" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Inlcude the PHPGrammar class file. | |
require("path/to/PHPGrammar.php"); | |
// An array to hold names and phone numbers of employees (you could easily get this from any data source). | |
$employees = Array(); | |
$employees[0] = Array("fname" => "Amanda", "lname" => "Hugankiss", "phone" => "7148596547"); | |
$employees[1] = Array("fname" => "Hugh", "lname" => "Jazz", "phone" => "7148745213"); | |
$employees[2] = Array("fname" => "Joe", "lname" => "Schmo", "phone" => "7845987456"); | |
$employees[3] = Array("fname" => "John", "lname" => "Public", "phone" => "4785412364"); | |
// Create a new grammar instance. | |
$grammar = new Grammar(false, "en-US", "voice", "menu"); | |
// Create a rule for the grammar. | |
$grammar->startRule("menu", GrammarScope::$public); | |
$grammar->startOneOf(); | |
// Iterate over the employees array. | |
for($i=0; $i<count($employees); $i++) { | |
$grammar->startItem(); | |
$grammar->item($employees[$i]["fname"], "0-1"); | |
$grammar->writeText($employees[$i]["lname"]); | |
$grammar->tag('out="'.$employees[$i]["phone"].'";'); | |
$grammar->endElement(); | |
} | |
$grammar->endElement(); // End element for one-of. | |
$grammar->endElement(); // End element for rule. | |
// Write the grammar out for applications to consume. | |
$grammar->writeGrammar(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment