// IMPORTANT: edit credentials.json // with your information // or comment out below /w your keys // //$cred = new Catapult\Credentials('BANDWIDTH_USER_ID', 'BANDWIDTH_API_TOKEN', 'BANDWIDTH_API_SECRET'); $cred = new Catapult\Credentials(); // dont forget to comment out the implicit version if using assoc array // this example is cli based // use like: // php ./sample-baml.php "verb" "attribute" "value" // example // php ./sample-baml.php "SpeakSentence" "voice" "female" $client = new Catapult\Client($cred); if (!(isset($argv[1]) || isset($argv[2]) || isset($argv[3]))) { die("\nPlease provide command line input like: \n php ./sample-verb.php 'verb' 'attribute' 'value'\n\n"); } try { $verb = $argv[1]; $attribute = $argv[2]; $value = $argv[3]; $baml = new Catapult\BaML(); $bverb = Catapult\BaMLVerb::fromString($verb); $bverb->create(array(new Catapult\BaMLAttribute($attribute, $value))); // here we can add other things // verbs, attributes or text $bverb->addText("example"); $baml->set($bverb); printf("The following BaML was generated: \n\n%s\n\n", $baml); } catch (\CatapultApiException $e) { echo var_dump($e); }
<?php require_once "../source/Catapult.php"; // below is a sample of Catapult of joining // multiple BaML verbs. // // This example uses 0.7.0 // please note Credentials object is not here // and does not need to be used anymore $client = new Catapult\Client(); $baml = new Catapult\BaML(); $gatherVerb = new Catapult\BaMLGather(); $speakSentenceVerb = new Catapult\BaMLSpeakSentence(); $gatherVerb->addAttribute("terminatingDigits", "#"); $gatherVerb->addAttribute("maxDigits", "10"); $speakSentenceVerb->addText("Hello this is just an example."); // this will nest one verb in another $gatherVerb->addVerb($speakSentenceVerb); // we can also directly edit the nested // verb using gatherVerb! $playAudio = new Catapult\BaMLPlayAudio(); $gatherVerb->addNestedVerb(0, $playAudio); // remember to add the verb in our root container // verbs need one root verb. $baml->set($gatherVerb); // lets dump our container echo var_dump($baml);
public function testGather() { $baml = new Catapult\BaML(); $verb = new Catapult\BaMLGather(); $verb->addAttribute("requestUrl", __DEFAULT_URL__); $verb->addAttribute("requestUrlTimeout", 5); $verb->addAttribute("maxDigits", 5); $verb->addAttribute("interDigitTimeout", 5); $verb->addAttribute("bargeable", 1); $verb->addAttribute("bargeable", 1); $baml->set($verb); $this->assertEquals(sizeof($baml->getVerbs()), 1); }