setting = $setting; //build the setting object and get the recording path $this->transcribe_key = $setting->get('audio', 'transcribe_key'); $this->transcribe_engine = $setting->get('audio', 'transcribe_engine'); $this->speech_key = $setting->get('audio', 'speech_key'); $this->speech_engine = $setting->get('audio', 'speech_engine'); } /** * speech - text to speech */ public function speech() { if (!empty($this->speech_engine)) { //set the class interface to use the _template suffix $classname = 'audio_'.$this->speech_engine; //load the class //require_once $classname . '.php'; //create the object $object = new $classname($this->setting); //ensure the class has implemented the audio_interface interface if ($object instanceof audio_interface) { $object->set_path($this->audio_path); $object->set_filename($this->audio_filename); $object->set_format($this->audio_format); $object->set_voice($this->audio_voice); $object->set_message($this->audio_message); $object->speech(); } else { return false; } } } /** * transcribe - speech to text */ public function transcribe() : string { if (!empty($this->transcribe_engine)) { //set the class interface to use the _template suffix $classname = 'audio_'.$this->transcribe_engine; //load the class //require_once $classname . '.php'; //create the object $object = new $classname($this->setting); //ensure the class has implemented the audio_interface interface if ($object instanceof audio_interface) { $object->set_path($this->audio_path); $object->set_filename($this->audio_filename); return $object->transcribe(); } else { return ''; } } } } } ?>