diff options
Diffstat (limited to 'apps/talk.c')
-rw-r--r-- | apps/talk.c | 56 |
1 files changed, 52 insertions, 4 deletions
diff --git a/apps/talk.c b/apps/talk.c index aae33283ae..bcf7a49acc 100644 --- a/apps/talk.c +++ b/apps/talk.c | |||
@@ -1191,6 +1191,33 @@ int talk_dir_or_spell(const char* dirname, | |||
1191 | } | 1191 | } |
1192 | #endif | 1192 | #endif |
1193 | 1193 | ||
1194 | /* Speak thumbnail for each component of a full path, again falling | ||
1195 | back or going straight to spelling depending on settings. */ | ||
1196 | int talk_fullpath(const char* path, bool enqueue) | ||
1197 | { | ||
1198 | if (!enqueue) | ||
1199 | talk_shutup(); | ||
1200 | if(path[0] != '/') | ||
1201 | /* path ought to start with /... */ | ||
1202 | return talk_spell(path, true); | ||
1203 | talk_id(VOICE_CHAR_SLASH, true); | ||
1204 | char buf[MAX_PATH]; | ||
1205 | strlcpy(buf, path, MAX_PATH); | ||
1206 | char *start = buf+1; /* start of current component */ | ||
1207 | char *ptr = strchr(start, '/'); /* end of current component */ | ||
1208 | while(ptr) { /* There are more slashes ahead */ | ||
1209 | /* temporarily poke a NULL at end of component to truncate string */ | ||
1210 | *ptr = '\0'; | ||
1211 | talk_dir_or_spell(buf, NULL, true); | ||
1212 | *ptr = '/'; /* restore string */ | ||
1213 | talk_id(VOICE_CHAR_SLASH, true); | ||
1214 | start = ptr+1; /* setup for next component */ | ||
1215 | ptr = strchr(start, '/'); | ||
1216 | } | ||
1217 | /* no more slashes, final component is a filename */ | ||
1218 | return talk_file_or_spell(NULL, buf, NULL, true); | ||
1219 | } | ||
1220 | |||
1194 | /* say a numeric value, this word ordering works for english, | 1221 | /* say a numeric value, this word ordering works for english, |
1195 | but not necessarily for other languages (e.g. german) */ | 1222 | but not necessarily for other languages (e.g. german) */ |
1196 | int talk_number(long n, bool enqueue) | 1223 | int talk_number(long n, bool enqueue) |
@@ -1257,6 +1284,27 @@ int talk_number(long n, bool enqueue) | |||
1257 | return 0; | 1284 | return 0; |
1258 | } | 1285 | } |
1259 | 1286 | ||
1287 | /* Say year like "nineteen ninety nine" instead of "one thousand 9 | ||
1288 | hundred ninety nine". */ | ||
1289 | static int talk_year(long year, bool enqueue) | ||
1290 | { | ||
1291 | int rem; | ||
1292 | if(year < 1100 || year >=2000) | ||
1293 | /* just say it as a regular number */ | ||
1294 | return talk_number(year, enqueue); | ||
1295 | /* Say century */ | ||
1296 | talk_number(year/100, enqueue); | ||
1297 | rem = year%100; | ||
1298 | if(rem == 0) | ||
1299 | /* as in 1900 */ | ||
1300 | return talk_id(VOICE_HUNDRED, true); | ||
1301 | if(rem <10) | ||
1302 | /* as in 1905 */ | ||
1303 | talk_id(VOICE_ZERO, true); | ||
1304 | /* sub-century year */ | ||
1305 | return talk_number(rem, true); | ||
1306 | } | ||
1307 | |||
1260 | /* Say time duration/interval. Input is time in seconds, | 1308 | /* Say time duration/interval. Input is time in seconds, |
1261 | say hours,minutes,seconds. */ | 1309 | say hours,minutes,seconds. */ |
1262 | static int talk_time_unit(long secs, bool enqueue) | 1310 | static int talk_time_unit(long secs, bool enqueue) |
@@ -1349,6 +1397,9 @@ int talk_value_decimal(long n, int unit, int decimals, bool enqueue) | |||
1349 | if (!check_audio_status()) | 1397 | if (!check_audio_status()) |
1350 | return -1; | 1398 | return -1; |
1351 | 1399 | ||
1400 | /* special pronounciation for year number */ | ||
1401 | if (unit == UNIT_DATEYEAR) | ||
1402 | return talk_year(n, enqueue); | ||
1352 | /* special case for time duration */ | 1403 | /* special case for time duration */ |
1353 | if (unit == UNIT_TIME) | 1404 | if (unit == UNIT_TIME) |
1354 | return talk_time_unit(n, enqueue); | 1405 | return talk_time_unit(n, enqueue); |
@@ -1496,10 +1547,7 @@ void talk_time(const struct tm *tm, bool enqueue) | |||
1496 | /* Voice the time in 24 hour format */ | 1547 | /* Voice the time in 24 hour format */ |
1497 | talk_number(tm->tm_hour, enqueue); | 1548 | talk_number(tm->tm_hour, enqueue); |
1498 | if (tm->tm_min == 0) | 1549 | if (tm->tm_min == 0) |
1499 | { | 1550 | talk_ids(true, VOICE_HUNDRED, VOICE_HOUR); |
1500 | talk_id(VOICE_HUNDRED, true); | ||
1501 | talk_id(VOICE_HOUR, true); | ||
1502 | } | ||
1503 | else | 1551 | else |
1504 | { | 1552 | { |
1505 | /* Pronounce the leading 0 */ | 1553 | /* Pronounce the leading 0 */ |