Fix the wavplay icon
[Rockbox.git] / apps / talk.c
blob04e37394b6ba3bf56e0568f5c9fed63ca220ac5e
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2004 Jörg Hohensohn
12 * This module collects the Talkbox and voice UI functions.
13 * (Talkbox reads directory names from mp3 clips called thumbnails,
14 * the voice UI lets menus and screens "talk" from a voicefile in memory.
16 * All files in this archive are subject to the GNU General Public License.
17 * See the file COPYING in the source tree root for full license agreement.
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
22 ****************************************************************************/
24 #include <stdio.h>
25 #include <stddef.h>
26 #include <string.h>
27 #include "file.h"
28 #include "buffer.h"
29 #include "system.h"
30 #include "kernel.h"
31 #include "settings.h"
32 #include "mp3_playback.h"
33 #include "audio.h"
34 #include "lang.h"
35 #include "talk.h"
36 #include "id3.h"
37 #include "logf.h"
38 #include "bitswap.h"
39 #include "structec.h"
40 #if CONFIG_CODEC == SWCODEC
41 #include "playback.h"
42 #endif
43 #include "debug.h"
46 /* Memory layout varies between targets because the
47 Archos (MASCODEC) devices cannot mix voice and audio playback
49 MASCODEC | MASCODEC | SWCODEC
50 (playing) | (stopped) |
51 audiobuf-----------+-----------+------------
52 audio | voice | thumbnail
53 |-----------|------------
54 | thumbnail | voice
55 | |------------
56 | | filebuf
57 | |------------
58 | | audio
59 | |------------
60 | | codec swap
61 audiobufend----------+-----------+------------
63 SWCODEC allocates dedicated buffers, MASCODEC reuses audiobuf. */
66 /***************** Constants *****************/
68 #define QUEUE_SIZE 64 /* must be a power of two */
69 #define QUEUE_MASK (QUEUE_SIZE-1)
70 const char* const dir_thumbnail_name = "_dirname.talk";
71 const char* const file_thumbnail_ext = ".talk";
73 /***************** Functional Macros *****************/
75 #define QUEUE_LEVEL ((queue_write - queue_read) & QUEUE_MASK)
77 #define LOADED_MASK 0x80000000 /* MSB */
79 #if CONFIG_CODEC == SWCODEC
80 #define MAX_THUMBNAIL_BUFSIZE 32768
81 #endif
83 #ifndef SIMULATOR
84 extern bool audio_is_initialized;
85 #endif
87 /***************** Data types *****************/
89 struct clip_entry /* one entry of the index table */
91 int offset; /* offset from start of voicefile file */
92 int size; /* size of the clip */
95 struct voicefile /* file format of our voice file */
97 int version; /* version of the voicefile */
98 int table; /* offset to index table, (=header size) */
99 int id1_max; /* number of "normal" clips contained in above index */
100 int id2_max; /* number of "voice only" clips contained in above index */
101 struct clip_entry index[]; /* followed by the index tables */
102 /* and finally the bitswapped mp3 clips, not visible here */
105 struct queue_entry /* one entry of the internal queue */
107 unsigned char* buf;
108 long len;
112 /***************** Globals *****************/
114 static unsigned char* p_thumbnail = NULL; /* buffer for thumbnail */
115 static long size_for_thumbnail; /* leftover buffer size for it */
116 static struct voicefile* p_voicefile; /* loaded voicefile */
117 static bool has_voicefile; /* a voicefile file is present */
118 static struct queue_entry queue[QUEUE_SIZE]; /* queue of scheduled clips */
119 static int queue_write; /* write index of queue, by application */
120 static int queue_read; /* read index of queue, by ISR context */
121 static int sent; /* how many bytes handed over to playback, owned by ISR */
122 static unsigned char curr_hd[3]; /* current frame header, for re-sync */
123 static int filehandle = -1; /* global, so the MMC variant can keep the file open */
124 static unsigned char* p_silence; /* VOICE_PAUSE clip, used for termination */
125 static long silence_len; /* length of the VOICE_PAUSE clip */
126 static unsigned char* p_lastclip; /* address of latest clip, for silence add */
127 static unsigned long voicefile_size = 0; /* size of the loaded voice file */
128 static unsigned char last_lang[MAX_FILENAME+1]; /* name of last used lang file (in talk_init) */
129 static bool talk_initialized; /* true if talk_init has been called */
131 /***************** Private prototypes *****************/
133 static void load_voicefile(void);
134 static void mp3_callback(unsigned char** start, int* size);
135 static int shutup(void);
136 static int queue_clip(unsigned char* buf, long size, bool enqueue);
137 static int open_voicefile(void);
138 static unsigned char* get_clip(long id, long* p_size);
141 /***************** Private implementation *****************/
143 static int open_voicefile(void)
145 char buf[64];
146 char* p_lang = "english"; /* default */
148 if ( global_settings.lang_file[0] &&
149 global_settings.lang_file[0] != 0xff )
150 { /* try to open the voice file of the selected language */
151 p_lang = (char *)global_settings.lang_file;
154 snprintf(buf, sizeof(buf), LANG_DIR "/%s.voice", p_lang);
156 return open(buf, O_RDONLY);
160 /* load the voice file into the mp3 buffer */
161 static void load_voicefile(void)
163 int load_size;
164 int got_size;
165 int file_size;
166 #if CONFIG_CODEC == SWCODEC
167 int length, i;
168 unsigned char *buf, temp;
169 #endif
171 filehandle = open_voicefile();
172 if (filehandle < 0) /* failed to open */
173 goto load_err;
175 file_size = filesize(filehandle);
176 if (file_size > audiobufend - audiobuf) /* won't fit? */
177 goto load_err;
179 #ifdef HAVE_MMC /* load only the header for now */
180 load_size = offsetof(struct voicefile, index);
181 #else /* load the full file */
182 load_size = file_size;
183 #endif
185 got_size = read(filehandle, audiobuf, load_size);
186 if (got_size != load_size /* failure */)
187 goto load_err;
189 #ifdef ROCKBOX_LITTLE_ENDIAN
190 logf("Byte swapping voice file");
191 structec_convert(audiobuf, "llll", 1, true);
192 #endif
194 if (((struct voicefile*)audiobuf)->table /* format check */
195 == offsetof(struct voicefile, index))
197 p_voicefile = (struct voicefile*)audiobuf;
199 #if CONFIG_CODEC != SWCODEC
200 /* MASCODEC: now use audiobuf for voice then thumbnail */
201 p_thumbnail = audiobuf + file_size;
202 p_thumbnail += (long)p_thumbnail % 2; /* 16-bit align */
203 size_for_thumbnail = audiobufend - p_thumbnail;
204 #endif
206 else
207 goto load_err;
209 #ifdef ROCKBOX_LITTLE_ENDIAN
210 for (i = 0; i < p_voicefile->id1_max + p_voicefile->id2_max; i++)
211 structec_convert(&p_voicefile->index[i], "ll", 1, true);
212 #endif
214 /* Do a bitswap as necessary. */
215 #if CONFIG_CODEC == SWCODEC
216 logf("Bitswapping voice file.");
217 cpu_boost(true);
218 buf = (unsigned char *)(&p_voicefile->index) +
219 (p_voicefile->id1_max + p_voicefile->id2_max) * sizeof(struct clip_entry);
220 length = file_size - (buf - (unsigned char *) p_voicefile);
222 for (i = 0; i < length; i++)
224 temp = buf[i];
225 temp = ((temp >> 4) & 0x0f) | ((temp & 0x0f) << 4);
226 temp = ((temp >> 2) & 0x33) | ((temp & 0x33) << 2);
227 buf[i] = ((temp >> 1) & 0x55) | ((temp & 0x55) << 1);
229 cpu_boost(false);
231 #endif
233 #ifdef HAVE_MMC
234 /* load the index table, now that we know its size from the header */
235 load_size = (p_voicefile->id1_max + p_voicefile->id2_max)
236 * sizeof(struct clip_entry);
237 got_size = read(filehandle,
238 (unsigned char *) p_voicefile + offsetof(struct voicefile, index), load_size);
239 if (got_size != load_size) /* read error */
240 goto load_err;
241 #else
242 close(filehandle); /* only the MMC variant leaves it open */
243 filehandle = -1;
244 #endif
246 /* make sure to have the silence clip, if available */
247 p_silence = get_clip(VOICE_PAUSE, &silence_len);
249 return;
251 load_err:
252 p_voicefile = NULL;
253 has_voicefile = false; /* don't try again */
254 if (filehandle >= 0)
256 close(filehandle);
257 filehandle = -1;
259 return;
263 /* called in ISR context if mp3 data got consumed */
264 static void mp3_callback(unsigned char** start, int* size)
266 queue[queue_read].len -= sent; /* we completed this */
267 queue[queue_read].buf += sent;
269 if (queue[queue_read].len > 0) /* current clip not finished? */
270 { /* feed the next 64K-1 chunk */
271 #if CONFIG_CODEC != SWCODEC
272 sent = MIN(queue[queue_read].len, 0xFFFF);
273 #else
274 sent = queue[queue_read].len;
275 #endif
276 *start = queue[queue_read].buf;
277 *size = sent;
278 return;
280 else if (sent > 0) /* go to next entry */
282 queue_read = (queue_read + 1) & QUEUE_MASK;
285 re_check:
287 if (QUEUE_LEVEL) /* queue is not empty? */
288 { /* start next clip */
289 #if CONFIG_CODEC != SWCODEC
290 sent = MIN(queue[queue_read].len, 0xFFFF);
291 #else
292 sent = queue[queue_read].len;
293 #endif
294 *start = p_lastclip = queue[queue_read].buf;
295 *size = sent;
296 curr_hd[0] = p_lastclip[1];
297 curr_hd[1] = p_lastclip[2];
298 curr_hd[2] = p_lastclip[3];
300 else if (p_silence != NULL /* silence clip available */
301 && p_lastclip != p_silence /* previous clip wasn't silence */
302 && p_lastclip != p_thumbnail) /* ..or thumbnail */
303 { /* add silence clip when queue runs empty playing a voice clip */
304 queue[queue_write].buf = p_silence;
305 queue[queue_write].len = silence_len;
306 queue_write = (queue_write + 1) & QUEUE_MASK;
308 goto re_check;
310 else
312 *size = 0; /* end of data */
316 /* stop the playback and the pending clips */
317 static int shutup(void)
319 #if CONFIG_CODEC != SWCODEC
320 unsigned char* pos;
321 unsigned char* search;
322 unsigned char* end;
323 #endif
325 if (QUEUE_LEVEL == 0) /* has ended anyway */
327 #if CONFIG_CODEC == SWCODEC
328 mp3_play_stop();
329 #endif
330 return 0;
332 #if CONFIG_CODEC != SWCODEC
333 #if CONFIG_CPU == SH7034
334 CHCR3 &= ~0x0001; /* disable the DMA (and therefore the interrupt also) */
335 #endif
336 /* search next frame boundary and continue up to there */
337 pos = search = mp3_get_pos();
338 end = queue[queue_read].buf + queue[queue_read].len;
340 if (pos >= queue[queue_read].buf
341 && pos <= end) /* really our clip? */
342 { /* (for strange reasons this isn't nesessarily the case) */
343 /* find the next frame boundary */
344 while (search < end) /* search the remaining data */
346 if (*search++ != 0xFF) /* quick search for frame sync byte */
347 continue; /* (this does the majority of the job) */
349 /* look at the (bitswapped) rest of header candidate */
350 if (search[0] == curr_hd[0] /* do the quicker checks first */
351 && search[2] == curr_hd[2]
352 && (search[1] & 0x30) == (curr_hd[1] & 0x30)) /* sample rate */
354 search--; /* back to the sync byte */
355 break; /* From looking at it, this is our header. */
359 if (search-pos)
360 { /* play old data until the frame end, to keep the MAS in sync */
361 sent = search-pos;
363 queue_write = (queue_read + 1) & QUEUE_MASK; /* will be empty after next callback */
364 queue[queue_read].len = sent; /* current one ends after this */
366 #if CONFIG_CPU == SH7034
367 DTCR3 = sent; /* let the DMA finish this frame */
368 CHCR3 |= 0x0001; /* re-enable DMA */
369 #endif
370 return 0;
373 #endif
375 /* nothing to do, was frame boundary or not our clip */
376 mp3_play_stop();
378 queue_write = queue_read = 0; /* reset the queue */
380 return 0;
384 /* schedule a clip, at the end or discard the existing queue */
385 static int queue_clip(unsigned char* buf, long size, bool enqueue)
387 int queue_level;
389 if (!enqueue)
390 shutup(); /* cut off all the pending stuff */
392 if (!size)
393 return 0; /* safety check */
394 #if CONFIG_CPU == SH7034
395 /* disable the DMA temporarily, to be safe of race condition */
396 CHCR3 &= ~0x0001;
397 #endif
398 queue_level = QUEUE_LEVEL; /* check old level */
400 if (queue_level < QUEUE_SIZE - 1) /* space left? */
402 queue[queue_write].buf = buf; /* populate an entry */
403 queue[queue_write].len = size;
404 queue_write = (queue_write + 1) & QUEUE_MASK;
407 if (queue_level == 0)
408 { /* queue was empty, we have to do the initial start */
409 p_lastclip = buf;
410 #if CONFIG_CODEC != SWCODEC
411 sent = MIN(size, 0xFFFF); /* DMA can do no more */
412 #else
413 sent = size;
414 #endif
415 mp3_play_data(buf, sent, mp3_callback);
416 curr_hd[0] = buf[1];
417 curr_hd[1] = buf[2];
418 curr_hd[2] = buf[3];
419 mp3_play_pause(true); /* kickoff audio */
421 else
423 #if CONFIG_CPU == SH7034
424 CHCR3 |= 0x0001; /* re-enable DMA */
425 #endif
428 return 0;
431 /* fetch a clip from the voice file */
432 static unsigned char* get_clip(long id, long* p_size)
434 long clipsize;
435 unsigned char* clipbuf;
437 if (id > VOICEONLY_DELIMITER)
438 { /* voice-only entries use the second part of the table */
439 id -= VOICEONLY_DELIMITER + 1;
440 if (id >= p_voicefile->id2_max)
441 return NULL; /* must be newer than we have */
442 id += p_voicefile->id1_max; /* table 2 is behind table 1 */
444 else
445 { /* normal use of the first table */
446 if (id >= p_voicefile->id1_max)
447 return NULL; /* must be newer than we have */
450 clipsize = p_voicefile->index[id].size;
451 if (clipsize == 0) /* clip not included in voicefile */
452 return NULL;
453 clipbuf = (unsigned char *) p_voicefile + p_voicefile->index[id].offset;
455 #ifdef HAVE_MMC /* dynamic loading, on demand */
456 if (!(clipsize & LOADED_MASK))
457 { /* clip used for the first time, needs loading */
458 lseek(filehandle, p_voicefile->index[id].offset, SEEK_SET);
459 if (read(filehandle, clipbuf, clipsize) != clipsize)
460 return NULL; /* read error */
462 p_voicefile->index[id].size |= LOADED_MASK; /* mark as loaded */
464 else
465 { /* clip is in memory already */
466 clipsize &= ~LOADED_MASK; /* without the extra bit gives true size */
468 #endif
470 *p_size = clipsize;
471 return clipbuf;
475 /* common code for talk_init() and talk_buffer_steal() */
476 static void reset_state(void)
478 queue_write = queue_read = 0; /* reset the queue */
479 p_voicefile = NULL; /* indicate no voicefile (trashed) */
480 #if CONFIG_CODEC == SWCODEC
481 /* Allocate a dedicated thumbnail buffer - once */
482 if (p_thumbnail == NULL)
484 size_for_thumbnail = audiobufend - audiobuf;
485 if (size_for_thumbnail > MAX_THUMBNAIL_BUFSIZE)
486 size_for_thumbnail = MAX_THUMBNAIL_BUFSIZE;
487 p_thumbnail = buffer_alloc(size_for_thumbnail);
489 #else
490 /* Just use the audiobuf, without allocating anything */
491 p_thumbnail = audiobuf;
492 size_for_thumbnail = audiobufend - audiobuf;
493 #endif
494 p_silence = NULL; /* pause clip not accessible */
497 /***************** Public implementation *****************/
499 void talk_init(void)
501 if (talk_initialized && !strcasecmp(last_lang, global_settings.lang_file))
503 /* not a new file, nothing to do */
504 return;
507 #ifdef HAVE_MMC
508 if (filehandle >= 0) /* MMC: An old voice file might still be open */
510 close(filehandle);
511 filehandle = -1;
513 #endif
515 talk_initialized = true;
516 strncpy((char *) last_lang, (char *)global_settings.lang_file,
517 MAX_FILENAME);
519 #if CONFIG_CODEC == SWCODEC
520 audio_get_buffer(false, NULL); /* Must tell audio to reinitialize */
521 #endif
522 reset_state(); /* use this for most of our inits */
524 filehandle = open_voicefile();
525 has_voicefile = (filehandle >= 0); /* test if we can open it */
526 voicefile_size = 0;
528 if (has_voicefile)
530 voicefile_size = filesize(filehandle);
531 close(filehandle); /* close again, this was just to detect presence */
532 filehandle = -1;
537 #if CONFIG_CODEC == SWCODEC
538 /* return if a voice codec is required or not */
539 bool talk_voice_required(void)
541 return (voicefile_size != 0) /* Voice file is available */
542 || (global_settings.talk_dir == 3) /* Thumbnail clips are required */
543 || (global_settings.talk_file == 3);
545 #endif
547 /* return size of voice file */
548 int talk_get_bufsize(void)
550 return voicefile_size;
553 /* somebody else claims the mp3 buffer, e.g. for regular play/record */
554 int talk_buffer_steal(void)
556 #if CONFIG_CODEC != SWCODEC
557 mp3_play_stop();
558 #endif
559 #ifdef HAVE_MMC
560 if (filehandle >= 0) /* only relevant for MMC */
562 close(filehandle);
563 filehandle = -1;
565 #endif
566 reset_state();
568 return 0;
572 /* play a voice ID from voicefile */
573 int talk_id(long id, bool enqueue)
575 long clipsize;
576 unsigned char* clipbuf;
577 int unit;
579 #if CONFIG_CODEC != SWCODEC
580 if (audio_status()) /* busy, buffer in use */
581 return -1;
582 #endif
584 if (p_voicefile == NULL && has_voicefile)
585 load_voicefile(); /* reload needed */
587 if (p_voicefile == NULL) /* still no voices? */
588 return -1;
590 if (id == -1) /* -1 is an indication for silence */
591 return -1;
593 /* check if this is a special ID, with a value */
594 unit = ((unsigned long)id) >> UNIT_SHIFT;
595 if (unit)
596 { /* sign-extend the value */
597 id = (unsigned long)id << (32-UNIT_SHIFT);
598 id >>= (32-UNIT_SHIFT);
599 talk_value(id, unit, enqueue); /* speak it */
600 return 0; /* and stop, end of special case */
603 clipbuf = get_clip(id, &clipsize);
604 if (clipbuf == NULL)
605 return -1; /* not present */
607 queue_clip(clipbuf, clipsize, enqueue);
609 return 0;
613 /* play a thumbnail from file */
614 int talk_file(const char* filename, bool enqueue)
616 int fd;
617 int size;
618 struct mp3entry info;
620 #if CONFIG_CODEC != SWCODEC
621 if (audio_status()) /* busy, buffer in use */
622 return -1;
623 #endif
625 if (p_thumbnail == NULL || size_for_thumbnail <= 0)
626 return -1;
628 if(mp3info(&info, filename, false)) /* use this to find real start */
630 return 0; /* failed to open, or invalid */
633 fd = open(filename, O_RDONLY);
634 if (fd < 0) /* failed to open */
636 return 0;
639 lseek(fd, info.first_frame_offset, SEEK_SET); /* behind ID data */
641 size = read(fd, p_thumbnail, size_for_thumbnail);
642 close(fd);
644 /* ToDo: find audio, skip ID headers and trailers */
646 if (size != 0 && size != size_for_thumbnail) /* Don't play missing or truncated clips */
648 #if CONFIG_CODEC != SWCODEC
649 bitswap(p_thumbnail, size);
650 #endif
651 queue_clip(p_thumbnail, size, enqueue);
654 return size;
658 /* say a numeric value, this word ordering works for english,
659 but not necessarily for other languages (e.g. german) */
660 int talk_number(long n, bool enqueue)
662 int level = 2; /* mille count */
663 long mil = 1000000000; /* highest possible "-illion" */
665 #if CONFIG_CODEC != SWCODEC
666 if (audio_status()) /* busy, buffer in use */
667 return -1;
668 #endif
670 if (!enqueue)
671 shutup(); /* cut off all the pending stuff */
673 if (n==0)
674 { /* special case */
675 talk_id(VOICE_ZERO, true);
676 return 0;
679 if (n<0)
681 talk_id(VOICE_MINUS, true);
682 n = -n;
685 while (n)
687 int segment = n / mil; /* extract in groups of 3 digits */
688 n -= segment * mil; /* remove the used digits from number */
689 mil /= 1000; /* digit place for next round */
691 if (segment)
693 int hundreds = segment / 100;
694 int ones = segment % 100;
696 if (hundreds)
698 talk_id(VOICE_ZERO + hundreds, true);
699 talk_id(VOICE_HUNDRED, true);
702 /* combination indexing */
703 if (ones > 20)
705 int tens = ones/10 + 18;
706 talk_id(VOICE_ZERO + tens, true);
707 ones %= 10;
710 /* direct indexing */
711 if (ones)
712 talk_id(VOICE_ZERO + ones, true);
714 /* add billion, million, thousand */
715 if (mil)
716 talk_id(VOICE_THOUSAND + level, true);
718 level--;
721 return 0;
724 /* singular/plural aware saying of a value */
725 int talk_value(long n, int unit, bool enqueue)
727 int unit_id;
728 static const int unit_voiced[] =
729 { /* lookup table for the voice ID of the units */
730 [0 ... UNIT_LAST-1] = -1, /* regular ID, int, signed */
731 [UNIT_MS]
732 = VOICE_MILLISECONDS, /* here come the "real" units */
733 [UNIT_SEC]
734 = VOICE_SECONDS,
735 [UNIT_MIN]
736 = VOICE_MINUTES,
737 [UNIT_HOUR]
738 = VOICE_HOURS,
739 [UNIT_KHZ]
740 = VOICE_KHZ,
741 [UNIT_DB]
742 = VOICE_DB,
743 [UNIT_PERCENT]
744 = VOICE_PERCENT,
745 [UNIT_MAH]
746 = VOICE_MILLIAMPHOURS,
747 [UNIT_PIXEL]
748 = VOICE_PIXEL,
749 [UNIT_PER_SEC]
750 = VOICE_PER_SEC,
751 [UNIT_HERTZ]
752 = VOICE_HERTZ,
753 [UNIT_MB]
754 = LANG_MEGABYTE,
755 [UNIT_KBIT]
756 = VOICE_KBIT_PER_SEC,
759 #if CONFIG_CODEC != SWCODEC
760 if (audio_status()) /* busy, buffer in use */
761 return -1;
762 #endif
764 if (unit < 0 || unit >= UNIT_LAST)
765 unit_id = -1;
766 else
767 unit_id = unit_voiced[unit];
769 if ((n==1 || n==-1) /* singular? */
770 && unit_id >= VOICE_SECONDS && unit_id <= VOICE_HOURS)
772 unit_id--; /* use the singular for those units which have */
775 /* special case with a "plus" before */
776 if (n > 0 && (unit == UNIT_SIGNED || unit == UNIT_DB))
778 talk_id(VOICE_PLUS, enqueue);
779 enqueue = true;
782 talk_number(n, enqueue); /* say the number */
783 talk_id(unit_id, true); /* say the unit, if any */
785 return 0;
788 /* spell a string */
789 int talk_spell(const char* spell, bool enqueue)
791 char c; /* currently processed char */
793 #if CONFIG_CODEC != SWCODEC
794 if (audio_status()) /* busy, buffer in use */
795 return -1;
796 #endif
798 if (!enqueue)
799 shutup(); /* cut off all the pending stuff */
801 while ((c = *spell++) != '\0')
803 /* if this grows into too many cases, I should use a table */
804 if (c >= 'A' && c <= 'Z')
805 talk_id(VOICE_CHAR_A + c - 'A', true);
806 else if (c >= 'a' && c <= 'z')
807 talk_id(VOICE_CHAR_A + c - 'a', true);
808 else if (c >= '0' && c <= '9')
809 talk_id(VOICE_ZERO + c - '0', true);
810 else if (c == '-')
811 talk_id(VOICE_MINUS, true);
812 else if (c == '+')
813 talk_id(VOICE_PLUS, true);
814 else if (c == '.')
815 talk_id(VOICE_DOT, true);
816 else if (c == ' ')
817 talk_id(VOICE_PAUSE, true);
820 return 0;