function ttsengines_hook_grammar($viewing_itemid, $target_menuid)
{
    global $db;
    $engines = ttsengines_get_all_engines();
    //Determine which engine is currently selected
    $sql = "select tts_engine from grammar_config";
    $selected_ttsengine = $db->getRow($sql, DB_FETCHMODE_ASSOC);
    if ($target_menuid = "grammar") {
        $html .= '<tr><td><a href=# class="info">' . _("Text-to-Speech Engine:") . '<span>' . _("Choose either the free Flite engine (requires flite and app_flite) or the paid Cepstral engine (requires app_cepstral)") . '<br></span></a></td><td align="right">';
        $html .= '<select name="tts_engine" tabindex="' . ++$tabindex . '">';
        if (empty($engines)) {
            $html .= '<option value="flite">Flite</option>';
            $html .= '<option value="Swift" >Cepstral</option>';
        } else {
            //the grammar module doesn't care about the path but actually wants the application name
            foreach ($engines as $engine) {
                $enginename = $engine['name'];
                $enginepath = $engine['path'];
                $html .= '<option value="';
                $html .= "{$enginename}";
                $html .= '"';
                //Show our use the one that have currently selected per our grammar_config database
                if ($selected_ttsengine['tts_engine'] == $enginename) {
                    $html .= 'SELECTED';
                }
                $html .= '>';
                $html .= "{$enginename}";
                $html .= '</option>';
            }
        }
        $html .= '</select>';
        $html .= '</td></tr>';
    }
    return $html;
}
$edit = $_GET['edit'];
$enginename = false;
$enginepath = false;
// Handle adding/updating an engine
if ($_REQUEST['delete']) {
    ttsengines_delete_engine($_REQUEST['engineid']);
} else {
    if ($_POST['edit']) {
        ttsengines_update_engine($_POST['engineid'], $_POST['enginename'], $_POST['enginepath']);
    } else {
        if ($_POST['addengine']) {
            ttsengines_add_engine($_POST['enginename'], $_POST['enginepath']);
        }
    }
}
$engines = ttsengines_get_all_engines();
$info = show_help(_('On this page you can manage text to speech engines on your system. When you add an engine you give it a name, and the full path to the engine on your system. After doing this the engine will be available on the text to speech page.'));
$heading = _('Text to Speech Engines');
$delurl = '';
if (isset($edit)) {
    $data = \FreePBX::Ttsengines()->getEngine($edit);
    $enginename = isset($data['name']) ? $data['name'] : '';
    $enginepath = isset($data['path']) ? $data['path'] : '';
    $delurl = '?display=ttsengines&delete=true&engineid=' . $edit . '&edit=' . $edit;
}
?>
<div class="container-fluid">
	<h1><?php 
echo $heading;
?>
</h1>
Esempio n. 3
0
//	License for all code of this FreePBX module can be found in the license file inside the module directory
//	Copyright 2013 Schmooze Com Inc.
//  Xavier Ourciere xourciere[at]propolys[dot]com
//
/**
 * This module REQUIRES the 'ttsengines' module. But since FreePBX
 *  doesn't handle circular dependancies, we have to force one.
 */
if (!function_exists('ttsengines_get_all_engines')) {
    show_view(__DIR__ . '/views/no-ttsengines.php');
    return;
}
//this function needs to be available to other modules (those that use goto destinations)
//therefore we put it in globalfunctions.php
$data['tts_list'] = tts_list();
$data['engine_list'] = ttsengines_get_all_engines();
$data['action'] = $_REQUEST['action'];
if ((isset($amp_conf['ASTVARLIBDIR']) ? $amp_conf['ASTVARLIBDIR'] : '') == '') {
    $astlib_path = "/var/lib/asterisk";
} else {
    $astlib_path = $amp_conf['ASTVARLIBDIR'];
}
$data['tts_astsnd_path'] = $astlib_path . "/sounds/tts/";
$data['tts_agi_error'] = null;
if (!($tts_agi = file_exists($astlib_path . "/agi-bin/propolys-tts.agi"))) {
    $data['tts_agi_error'] = _("AGI script not found");
}
if (!empty($_REQUEST['id']) || $action !== 'delete') {
    $tts = tts_get($_REQUEST['id']);
    foreach ($tts as $key => $value) {
        $data[$key] = $value;