2 * Navit, a modular navigation system.
3 * Copyright (C) 2005-2008 Navit Team
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
28 struct speech_priv *priv;
29 struct speech_methods meth;
35 speech_new(struct attr *parent, struct attr **attrs)
38 struct speech_priv *(*speech_new)(struct speech_methods *meth, struct attr **attrs);
41 attr=attr_search(attrs, NULL, attr_type);
43 dbg(0,"type missing\n");
46 dbg(1,"type='%s'\n", attr->u.str);
47 speech_new=plugin_get_speech_type(attr->u.str);
48 dbg(1,"new=%p\n", speech_new);
50 dbg(0,"wrong type '%s'\n", attr->u.str);
53 this_=g_new0(struct speech, 1);
54 this_->priv=speech_new(&this_->meth, attrs);
55 this_->attrs=attr_list_dup(attrs);
56 dbg(1, "say=%p\n", this_->meth.say);
57 dbg(1,"priv=%p\n", this_->priv);
62 dbg(1,"return %p\n", this_);
68 speech_say(struct speech *this_, const char *text)
70 dbg(1, "this_=%p text='%s' calling %p\n", this_, text, this_->meth.say);
71 return (this_->meth.say)(this_->priv, text);
75 * @brief Gets an attribute from a speech plugin
77 * @param this_ The speech plugin the attribute should be read from
78 * @param type The type of the attribute to be read
79 * @param attr Pointer to an attrib-structure where the attribute should be written to
80 * @param iter (NOT IMPLEMENTED) Used to iterate through all attributes of a type. Set this to NULL to get the first attribute, set this to an attr_iter to get the next attribute
81 * @return True if the attribute type was found, false if not
85 speech_get_attr(struct speech *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
87 return attr_generic_get_attr(this_->attrs, NULL, type, attr, iter);
91 * @brief Tries to estimate how long it will take to speak a certain string
93 * This function tries to estimate how long it will take to speak a certain string
94 * passed in str. It relies on the "characters per second"-value passed from the
97 * @param this_ The speech whose speed should be used
98 * @param str The string that should be estimated
99 * @return Time in tenth of seconds or -1 on error
102 speech_estimate_duration(struct speech *this_, char *str)
105 struct attr cps_attr;
107 if (!speech_get_attr(this_,attr_cps,&cps_attr,NULL)) {
113 return (count * 10) / cps_attr.u.num;
117 * @brief Sets an attribute from an speech plugin
119 * This sets an attribute of a speech plugin, overwriting an attribute of the same type if it
120 * already exists. This function also calls all the callbacks that are registred
121 * to be called when attributes change.
123 * @param this_ The speech plugin to set the attribute of
124 * @param attr The attribute to set
125 * @return True if the attr could be set, false otherwise
129 speech_set_attr(struct speech *this_, struct attr *attr)
131 this_->attrs=attr_generic_set_attr(this_->attrs, attr);
132 //callback_list_call_attr_2(this_->attr_cbl, attr->type, this_, attr);