<commit_before><?php
/**
 * This file contains PHP classes that can be used to interact with the Tropo WebAPI/
 * @see https://www.tropo.com/docs/webapi/
 * 
 * @copyright 2010 <NAME> (http://www.voiceingov.org)
 * @package TropoPHP
 * @author <NAME>
 * @author <NAME>
 */

/**
 * The main Tropo WebAPI class.
 * The methods on this class can be used to invoke specifc Tropo actions.
 * @package TropoPHP
 * @see https://www.tropo.com/docs/webapi/tropo.htm
 *
 */
include 'tropo-rest.class.php';

class Tropo extends BaseClass {
	
	/**
	 * The container for JSON actions.
	 *
	 * @var array
	 * @access private
	 */
	public $tropo;
	
	/**
	 * The TTS voice to use when rendering content.
	 *
	 * @var string
	 * @access private
	 */
	private $_voice;
	
	/**
	 * The language to use when rendering content.
	 *
	 * @var string
	 * @access private
	 */
	private $_language;
	
	/**
	 * Class constructor for the Tropo class.
	 * @access private
	 */
	public function __construct() {
		$this->tropo = array();
	}
	
	/**
	 * Set a default voice for use with all Text To Speech.
	 *
	 * Tropo's text to speech engine can pronounce your text with
	 * a variety of voices in different languages. All elements where
	 * you can create text to speech (TTS) accept a voice parameter.
	 * Tropo's default is "Allison" but you can set a default for this
	 * script here.
	 *
	 * @param string $voice
	 */
	public function setVoice($voice) {
		$this->_voice = $voice;
	}
	
	/**
	 * Set a default language to use in speech recognition.
	 *
	 * When recognizing spoken input, Tropo allows you to set a language
	 * to let the platform know which language is being spoken and which
	 * recognizer to use. The default is en-us (US English), but you can
	 * set a different default to be used in your application here.
	 *
	 * @param string $language
	 */
	public function setLanguage($language) {
		$this->_language = $language;
	}
		
	/**
	 * Sends a prompt to the user and optionally waits for a response.
	 *
	 * The ask method allows for collecting input using either speech 
	 * recognition or DTMF (also known as Touch Tone). You can either 
	 * pass in a fully-formed Ask object or a string to use as the 
	 * prompt and an array of parameters.
	 *
	 * @param string|Ask $ask
	 * @param array $params
	 * @see https://www.tropo.com/docs/webapi/ask.htm
	 */
	public function ask($ask, Array $params=NULL) {
		if(!is_object($ask)) {
		  $p = array('as','event','voice','attempts', 'bargein', 'minConfidence', 'name', 'required', 'timeout', 'allowSignals');
			foreach ($p as $option) {
	      $$option = null;
  	    if (is_array($params) && array_key_exists($option, $params)) {
  	    	$$option = $params[$option];
  	    }
  		}
	  	$say[] = new Say($ask, $as, null, $voice);
	  	if (is_array($event)) {
	  	    // If an event was passed in, add the events to the Ask
    		  foreach ($event as $e => $val){
    		    $say[] = new Say($val, $as, $e, $voice); 
    		  }
	  	}
	  	$params["mode"] = isset($params["mode"]) ? $params["mode"] : null;
	  	$params["dtmf"] = isset($params["dtmf"]) ? $params["dtmf"] : null;
	  	$params["terminator"] = isset($params["terminator"]) ? $params["terminator"] : null;
	  	$voice = isset($this->_voice) ? $this->_voice : null;
		$choices = isset($params["choices"]) ? new Choices($params["choices"], $params["mode"], $params["terminator"]) : null;
	  	$ask = new Ask($attempts, $bargein, $choices, $minConfidence, $name, $required, $say, $timeout, $voice, $allowSignals);
 		}<commit_msg>(Fix) Voice on Tropo::ask() does not work<commit_after><?php
/**
 * This file contains PHP classes that can be used to interact with the Tropo WebAPI/
 * @see https://www.tropo.com/docs/webapi/
 * 
 * @copyright 2010 <NAME> (http://www.voiceingov.org)
 * @package TropoPHP
 * @author <NAME>
 * @author <NAME>
 */

/**
 * The main Tropo WebAPI class.
 * The methods on this class can be used to invoke specifc Tropo actions.
 * @package TropoPHP
 * @see https://www.tropo.com/docs/webapi/tropo.htm
 *
 */
include 'tropo-rest.class.php';

class Tropo extends BaseClass {
	
	/**
	 * The container for JSON actions.
	 *
	 * @var array
	 * @access private
	 */
	public $tropo;
	
	/**
	 * The TTS voice to use when rendering content.
	 *
	 * @var string
	 * @access private
	 */
	private $_voice;
	
	/**
	 * The language to use when rendering content.
	 *
	 * @var string
	 * @access private
	 */
	private $_language;
	
	/**
	 * Class constructor for the Tropo class.
	 * @access private
	 */
	public function __construct() {
		$this->tropo = array();
	}
	
	/**
	 * Set a default voice for use with all Text To Speech.
	 *
	 * Tropo's text to speech engine can pronounce your text with
	 * a variety of voices in different languages. All elements where
	 * you can create text to speech (TTS) accept a voice parameter.
	 * Tropo's default is "Allison" but you can set a default for this
	 * script here.
	 *
	 * @param string $voice
	 */
	public function setVoice($voice) {
		$this->_voice = $voice;
	}
	
	/**
	 * Set a default language to use in speech recognition.
	 *
	 * When recognizing spoken input, Tropo allows you to set a language
	 * to let the platform know which language is being spoken and which
	 * recognizer to use. The default is en-us (US English), but you can
	 * set a different default to be used in your application here.
	 *
	 * @param string $language
	 */
	public function setLanguage($language) {
		$this->_language = $language;
	}
		
	/**
	 * Sends a prompt to the user and optionally waits for a response.
	 *
	 * The ask method allows for collecting input using either speech 
	 * recognition or DTMF (also known as Touch Tone). You can either 
	 * pass in a fully-formed Ask object or a string to use as the 
	 * prompt and an array of parameters.
	 *
	 * @param string|Ask $ask
	 * @param array $params
	 * @see https://www.tropo.com/docs/webapi/ask.htm
	 */
	public function ask($ask, Array $params=NULL) {
		if(!is_object($ask)) {
		  $p = array('as','event','voice','attempts', 'bargein', 'minConfidence', 'name', 'required', 'timeout', 'allowSignals');
			foreach ($p as $option) {
	      $$option = null;
  	    if (is_array($params) && array_key_exists($option, $params)) {
  	    	$$option = $params[$option];
  	    }
  		}
	  	$say[] = new Say($ask, $as, null, $voice);
	  	if (is_array($event)) {
	  	    // If an event was passed in, add the events to the Ask
    		  foreach ($event as $e => $val){
    		    $say[] = new Say($val, $as, $e, $voice); 
    		  }
	  	}
	  	$params["mode"] = isset($params["mode"]) ? $params["mode"] : null;
	  	$params["dtmf"] = isset($params["dtmf"]) ? $params["dtmf"] : null;
	  	$params["terminator"] = isset($params["terminator"]) ? $params["terminator"] : null;
	  	if (!isset($voice) && isset($this->_voice)) {
	  	   $voice = $this->_voice;
	  	}
		  $choices = isset($params["choices"]) ? new Choices($params["choices"], $params["mode"], $params["terminator"]) : null;
	  	$ask = new Ask($attempts, $bargein, $choices, $minConfidence, $name, $required, $say, $timeout, $voice, $allowSignals);
 		}
{'fraction_non_alphanumeric': 0.1432802143562262, 'fraction_numerical': 0.0011281906642222536, 'mean_word_length': 3.157092614302462, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 21, 'https://': 6, 'lorem ipsum': 0, 'www.': 8, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2526413', 'n_tokens_mistral': 2447, 'n_tokens_neox': 2240, 'n_words': 779}