<?php
/**
* gonx_synthesis class :
*
* @package GONX
* @author Ben Yacoub Hatem <hide@address.com>
* @copyright Copyright (c) 2004
* @version $Id: synthesis.class.php,v 1.3 2004/11/05 07:59:42 hatemben Exp $ - 2004-10-25 11:34:45 - speak.class.php
* @generator dtd2php version 1.0.1
* @access public
**/
class gonx_synthesis{
/**
* Constructor
* @access protected
*/
function gonx_synthesis(){
$this->_document = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
}
var $_document;
/*
* Open speak tag.
*
* @param version this variable is required
* @param xml_lang this variable is required
* @param xmlns_xsi
* @param xsi_schemaLocation
* @param xml_base
*/
function start_speak($version = "", $xml_lang = "", $xmlns_xsi = "", $xsi_schemaLocation = "", $xml_base = "")
{
$resu = ("<speak");
if ((isset($version)) and ($version!=="")){
$resu .= ' version="'.$version.'"';
} else {
$resu .= ' <!-- Error occured in speak. Need to pass "version"=... -->';
}
if ((isset($xml_lang)) and ($xml_lang!=="")){
$resu .= ' xml:lang="'.$xml_lang.'"';
} else {
$resu .= ' <!-- Error occured in speak. Need to pass "xml:lang"=... -->';
}
$resu .= ' xmlns = \'http://www.w3.org/2001/10/synthesis\' ';
if ((isset($xmlns_xsi)) and ($xmlns_xsi!=="")){
$resu .= ' xmlns:xsi="'.$xmlns_xsi.'"';
}
if ((isset($xsi_schemaLocation)) and ($xsi_schemaLocation!=="")){
$resu .= ' xsi:schemaLocation="'.$xsi_schemaLocation.'"';
}
if ((isset($xml_base)) and ($xml_base!=="")){
$resu .= ' xml:base="'.$xml_base.'"';
}
$resu .= (">\n ");
$this->_document .= $resu;
}
/*
* Close speak tag.
*
*/
function end_speak()
{
$this->_document .= "</speak>\n";
}
/*
* Open p tag.
*
* @param xml_lang
*/
function start_p($xml_lang = "")
{
$resu = ("<p");
if ((isset($xml_lang)) and ($xml_lang!=="")){
$resu .= ' xml:lang="'.$xml_lang.'"';
}
$resu .= (">\n ");
$this->_document .= $resu;
}
/*
* Close p tag.
*
*/
function end_p()
{
$this->_document .= "</p>\n";
}
/*
* Open s tag.
*
* @param xml_lang
*/
function start_s($xml_lang = "")
{
$resu = ("<s");
if ((isset($xml_lang)) and ($xml_lang!=="")){
$resu .= ' xml:lang="'.$xml_lang.'"';
}
$resu .= (">\n ");
$this->_document .= $resu;
}
/*
* Close s tag.
*
*/
function end_s()
{
$this->_document .= "</s>\n";
}
/*
* Open voice tag.
*
* @param xml_lang
* @param gender
* @param age
* @param variant
* @param name
*/
function start_voice($xml_lang = "", $gender = "", $age = "", $variant = "", $name = "")
{
$resu = ("<voice");
if ((isset($xml_lang)) and ($xml_lang!=="")){
$resu .= ' xml:lang="'.$xml_lang.'"';
}
if ((isset($gender)) and ($gender!=="")){
$resu .= ' gender="'.$gender.'"';
}
if ((isset($age)) and ($age!=="")){
$resu .= ' age="'.$age.'"';
}
if ((isset($variant)) and ($variant!=="")){
$resu .= ' variant="'.$variant.'"';
}
if ((isset($name)) and ($name!=="")){
$resu .= ' name="'.$name.'"';
}
$resu .= (">\n ");
$this->_document .= $resu;
}
/*
* Close voice tag.
*
*/
function end_voice()
{
$this->_document .= "</voice>\n";
}
/*
* Open prosody tag.
*
* @param pitch
* @param contour
* @param range
* @param rate
* @param duration
* @param volume
*/
function start_prosody($pitch = "", $contour = "", $range = "", $rate = "", $duration = "", $volume = "")
{
$resu = ("<prosody");
if ((isset($pitch)) and ($pitch!=="")){
$resu .= ' pitch="'.$pitch.'"';
}
if ((isset($contour)) and ($contour!=="")){
$resu .= ' contour="'.$contour.'"';
}
if ((isset($range)) and ($range!=="")){
$resu .= ' range="'.$range.'"';
}
if ((isset($rate)) and ($rate!=="")){
$resu .= ' rate="'.$rate.'"';
}
if ((isset($duration)) and ($duration!=="")){
$resu .= ' duration="'.$duration.'"';
}
if ((isset($volume)) and ($volume!=="")){
$resu .= ' volume="'.$volume.'"';
}
$resu .= (">\n ");
$this->_document .= $resu;
}
/*
* Close prosody tag.
*
*/
function end_prosody()
{
$this->_document .= "</prosody>\n";
}
/*
* Open audio tag.
*
* @param src this variable is required
*/
function start_audio($src = "")
{
$resu = ("<audio");
if ((isset($src)) and ($src!=="")){
$resu .= ' src="'.$src.'"';
} else {
$resu .= ' <!-- Error occured in audio. Need to pass "src"=... -->';
}
$resu .= (">\n ");
$this->_document .= $resu;
}
/*
* Close audio tag.
*
*/
function end_audio()
{
$this->_document .= "</audio>\n";
}
/*
* Open desc tag.
*
* @param xml_lang
*/
function start_desc($xml_lang = "")
{
$resu = ("<desc");
if ((isset($xml_lang)) and ($xml_lang!=="")){
$resu .= ' xml:lang="'.$xml_lang.'"';
}
$resu .= (">\n ");
$this->_document .= $resu;
}
/*
* Close desc tag.
*
*/
function end_desc()
{
$this->_document .= "</desc>\n";
}
/*
* Open emphasis tag.
*
* @param level
*/
function start_emphasis($level = "")
{
$resu = ("<emphasis");
if ((isset($level)) and ($level!=="")){
$resu .= ' level="'.$level.'"';
}
$resu .= (">\n ");
$this->_document .= $resu;
}
/*
* Close emphasis tag.
*
*/
function end_emphasis()
{
$this->_document .= "</emphasis>\n";
}
/*
* Open say_as tag.
*
* @param interpret_as this variable is required
* @param format
* @param detail
*/
function start_say_as($interpret_as = "", $format = "", $detail = "")
{
$resu = ("<say-as");
if ((isset($interpret_as)) and ($interpret_as!=="")){
$resu .= ' interpret-as="'.$interpret_as.'"';
} else {
$resu .= ' <!-- Error occured in say-as. Need to pass "interpret-as"=... -->';
}
if ((isset($format)) and ($format!=="")){
$resu .= ' format="'.$format.'"';
}
if ((isset($detail)) and ($detail!=="")){
$resu .= ' detail="'.$detail.'"';
}
$resu .= (">\n ");
$this->_document .= $resu;
}
/*
* Close say_as tag.
*
*/
function end_say_as()
{
$this->_document .= "</say-as>\n";
}
/*
* Open sub tag.
*
* @param alias this variable is required
*/
function start_sub($alias = "")
{
$resu = ("<sub");
if ((isset($alias)) and ($alias!=="")){
$resu .= ' alias="'.$alias.'"';
} else {
$resu .= ' <!-- Error occured in sub. Need to pass "alias"=... -->';
}
$resu .= (">\n ");
$this->_document .= $resu;
}
/*
* Close sub tag.
*
*/
function end_sub()
{
$this->_document .= "</sub>\n";
}
/*
* Open phoneme tag.
*
* @param ph this variable is required
* @param alphabet
*/
function start_phoneme($ph = "", $alphabet = "")
{
$resu = ("<phoneme");
if ((isset($ph)) and ($ph!=="")){
$resu .= ' ph="'.$ph.'"';
} else {
$resu .= ' <!-- Error occured in phoneme. Need to pass "ph"=... -->';
}
if ((isset($alphabet)) and ($alphabet!=="")){
$resu .= ' alphabet="'.$alphabet.'"';
}
$resu .= (">\n ");
$this->_document .= $resu;
}
/*
* Close phoneme tag.
*
*/
function end_phoneme()
{
$this->_document .= "</phoneme>\n";
}
/*
* Open break tag.
*
* @param time
* @param strength
*/
function start_break($time = "", $strength = "")
{
$resu = '<break';
if ((isset($time)) and ($time!=="")){
$resu .= ' time="'.$time.'"';
}
if ((isset($strength)) and ($strength!=="")){
$resu .= ' strength="'.$strength.'"';
}
$resu .= ">\n ";
$this->_document .= $resu;
}
/*
* Close break tag.
*
*/
function end_break()
{
$this->_document .= "</break>\n";
}
/*
* Open mark tag.
*
* @param name this variable is required
*/
function start_mark($name = "")
{
$resu = '<mark';
if ((isset($name)) and ($name!=="")){
$resu .= ' name="'.$name.'"';
} else {
$resu .= ' <!-- Error occured in mark. Need to pass "name"=... -->';
}
$resu .= ">\n ";
$this->_document .= $resu;
}
/*
* Close mark tag.
*
*/
function end_mark()
{
$this->_document .= "</mark>\n";
}
/*
* Open lexicon tag.
*
* @param uri this variable is required
* @param type
*/
function start_lexicon($uri = "", $type = "")
{
$resu = '<lexicon';
if ((isset($uri)) and ($uri!=="")){
$resu .= ' uri="'.$uri.'"';
} else {
$resu .= ' <!-- Error occured in lexicon. Need to pass "uri"=... -->';
}
if ((isset($type)) and ($type!=="")){
$resu .= ' type="'.$type.'"';
}
$resu .= ">\n ";
$this->_document .= $resu;
}
/*
* Close lexicon tag.
*
*/
function end_lexicon()
{
$this->_document .= "</lexicon>\n";
}
/*
* Open metadata tag.
*/
function start_metadata()
{
$this->_document .= "<metadata>\n";
}
/*
* Close metadata tag.
*
*/
function end_metadata()
{
$this->_document .= "</metadata>\n";
}
/*
* Create meta tag.
*/
function start_meta()
{
$this->_document .= "<meta />\n";
}
/*
*
* Load a synthesis Module to extends class funtionnalities.
*
*/
function load($module,$params)
{
if (ereg('::',$module)) {
$d = explode('::',$module);
$module = $d[0];
$method = $d[1];
}
// Usage of absolute path to library
if (ereg('WIN',PHP_OS)) {
$path = explode('\\', __FILE__);
} else $path = explode('/', __FILE__);
array_pop($path) ;
$path = implode('/',$path);
if (is_file("$path/synthesis_mods/{$module}.class.php")) {
require_once("$path/synthesis_mods/$module.class.php");
$m = new $module($this,$params);
if (isset($method)) {
$m->$method($params);
}
}
}
/*
*
* Echo generated speak application to user.
*
*/
function generate()
{
echo $this->_document;
}
}
?>