diff options
author | tinloaf <tinloaf@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2009-01-05 20:32:31 +0000 |
---|---|---|
committer | tinloaf <tinloaf@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2009-01-05 20:32:31 +0000 |
commit | 1f66c15125f31d9d6fa63ea83f67e2bbbfc025f8 (patch) | |
tree | 751c02dec25b760b95aeed58badab12405b1ed96 /navit/speech.c | |
parent | d076e8d5ee0ddf6ef30065bf4b89af5ce79327f8 (diff) | |
download | navit-1f66c15125f31d9d6fa63ea83f67e2bbbfc025f8.tar.gz |
Add:Core:Adding estimate of duration of speech
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@1898 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/speech.c')
-rw-r--r-- | navit/speech.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/navit/speech.c b/navit/speech.c index 817832dcf..b3df16941 100644 --- a/navit/speech.c +++ b/navit/speech.c @@ -88,6 +88,32 @@ speech_get_attr(struct speech *this_, enum attr_type type, struct attr *attr, st } /** + * @brief Tries to estimate how long it will take to speak a certain string + * + * This function tries to estimate how long it will take to speak a certain string + * passed in str. It relies on the "characters per second"-value passed from the + * configuration. + * + * @param this_ The speech whose speed should be used + * @param str The string that should be estimated + * @return Time in tenth of seconds or -1 on error + */ +int +speech_estimate_duration(struct speech *this_, char *str) +{ + int count; + struct attr cps_attr; + + if (!speech_get_attr(this_,attr_cps,&cps_attr,NULL)) { + return -1; + } + + count = strlen(str); + + return (count * 10) / cps_attr.u.num; +} + +/** * @brief Sets an attribute from an speech plugin * * This sets an attribute of a speech plugin, overwriting an attribute of the same type if it |