Small '#ifdef HAVE_TAGCACHE' fix
[Rockbox.git] / apps / talk.c
blob6629bbb2e5554339100c587f4b0d813a16298a59
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 "settings.h"
31 #include "mp3_playback.h"
32 #include "audio.h"
33 #include "lang.h"
34 #include "talk.h"
35 #include "id3.h"
36 #include "logf.h"
37 #include "bitswap.h"
38 #include "structec.h"
39 #if CONFIG_CODEC == SWCODEC
40 #include "playback.h"
41 #endif
42 #include "debug.h"
45 /* Memory layout varies between targets because the
46 Archos (MASCODEC) devices cannot mix voice and audio playback
48 MASCODEC | MASCODEC | SWCODEC
49 (playing) | (stopped) |
50 audiobuf-----------+-----------+------------
51 audio | voice | thumbnail
52 |-----------|------------
53 | thumbnail | voice
54 | |------------
55 | | filebuf
56 | |------------
57 | | audio
58 | |------------
59 | | codec swap
60 audiobufend----------+-----------+------------
62 SWCODEC allocates dedicated buffers, MASCODEC reuses audiobuf. */
65 /***************** Constants *****************/
67 #define QUEUE_SIZE 64 /* must be a power of two */
68 #define QUEUE_MASK (QUEUE_SIZE-1)
69 const char* const dir_thumbnail_name = "_dirname.talk";
70 const char* const file_thumbnail_ext = ".talk";
72 /***************** Functional Macros *****************/
74 #define QUEUE_LEVEL ((queue_write - queue_read) & QUEUE_MASK)
76 #define LOADED_MASK 0x80000000 /* MSB */
78 #if CONFIG_CODEC == SWCODEC
79 #define MAX_THUMBNAIL_BUFSIZE 32768
80 #endif
83 /***************** Data types *****************/
85 struct clip_entry /* one entry of the index table */
87 int offset; /* offset from start of voicefile file */
88 int size; /* size of the clip */
91 struct voicefile /* file format of our voice file */
93 int version; /* version of the voicefile */
94 int table; /* offset to index table, (=header size) */
95 int id1_max; /* number of "normal" clips contained in above index */
96 int id2_max; /* number of "voice only" clips contained in above index */
97 struct clip_entry index[]; /* followed by the index tables */
98 /* and finally the bitswapped mp3 clips, not visible here */
101 struct queue_entry /* one entry of the internal queue */
103 unsigned char* buf;
104 long len;
108 /***************** Globals *****************/
110 static unsigned char* p_thumbnail = NULL; /* buffer for thumbnail */
111 static long size_for_thumbnail; /* leftover buffer size for it */
112 static struct voicefile* p_voicefile; /* loaded voicefile */
113 static bool has_voicefile; /* a voicefile file is present */
114 static struct queue_entry queue[QUEUE_SIZE]; /* queue of scheduled clips */
115 static int queue_write; /* write index of queue, by application */
116 static int queue_read; /* read index of queue, by ISR context */
117 static int sent; /* how many bytes handed over to playback, owned by ISR */
118 static unsigned char curr_hd[3]; /* current frame header, for re-sync */
119 static int filehandle = -1; /* global, so the MMC variant can keep the file open */
120 static unsigned char* p_silence; /* VOICE_PAUSE clip, used for termination */
121 static long silence_len; /* length of the VOICE_PAUSE clip */
122 static unsigned char* p_lastclip; /* address of latest clip, for silence add */
123 static unsigned long voicefile_size = 0; /* size of the loaded voice file */
124 static unsigned char last_lang[MAX_FILENAME+1]; /* name of last used lang file (in talk_init) */
125 static bool talk_initialized; /* true if talk_init has been called */
127 /***************** Private prototypes *****************/
129 static void load_voicefile(void);
130 static void mp3_callback(unsigned char** start, int* size);
131 static int shutup(void);
132 static int queue_clip(unsigned char* buf, long size, bool enqueue);
133 static int open_voicefile(void);
134 static unsigned char* get_clip(long id, long* p_size);
137 /***************** Private implementation *****************/
139 static int open_voicefile(void)
141 char buf[64];
142 char* p_lang = "english"; /* default */
144 if ( global_settings.lang_file[0] &&
145 global_settings.lang_file[0] != 0xff )
146 { /* try to open the voice file of the selected language */
147 p_lang = (char *)global_settings.lang_file;
150 snprintf(buf, sizeof(buf), LANG_DIR "/%s.voice", p_lang);
152 return open(buf, O_RDONLY);
156 /* load the voice file into the mp3 buffer */
157 static void load_voicefile(void)
159 int load_size;
160 int got_size;
161 int file_size;
162 #if CONFIG_CODEC == SWCODEC
163 int length, i;
164 unsigned char *buf, temp;
165 #endif
167 filehandle = open_voicefile();
168 if (filehandle < 0) /* failed to open */
169 goto load_err;
171 file_size = filesize(filehandle);
172 if (file_size > audiobufend - audiobuf) /* won't fit? */
173 goto load_err;
175 #ifdef HAVE_MMC /* load only the header for now */
176 load_size = offsetof(struct voicefile, index);
177 #else /* load the full file */
178 load_size = file_size;
179 #endif
181 got_size = read(filehandle, audiobuf, load_size);
182 if (got_size != load_size /* failure */)
183 goto load_err;
185 #ifdef ROCKBOX_LITTLE_ENDIAN
186 logf("Byte swapping voice file");
187 structec_convert(audiobuf, "llll", 1, true);
188 #endif
190 if (((struct voicefile*)audiobuf)->table /* format check */
191 == offsetof(struct voicefile, index))
193 p_voicefile = (struct voicefile*)audiobuf;
195 #if CONFIG_CODEC != SWCODEC
196 /* MASCODEC: now use audiobuf for voice then thumbnail */
197 p_thumbnail = audiobuf + file_size;
198 p_thumbnail += (long)p_thumbnail % 2; /* 16-bit align */
199 size_for_thumbnail = audiobufend - p_thumbnail;
200 #endif
202 else
203 goto load_err;
205 #ifdef ROCKBOX_LITTLE_ENDIAN
206 for (i = 0; i < p_voicefile->id1_max + p_voicefile->id2_max; i++)
207 structec_convert(&p_voicefile->index[i], "ll", 1, true);
208 #endif
210 /* Do a bitswap as necessary. */
211 #if CONFIG_CODEC == SWCODEC
212 logf("Bitswapping voice file.");
213 cpu_boost(true);
214 buf = (unsigned char *)(&p_voicefile->index) +
215 (p_voicefile->id1_max + p_voicefile->id2_max) * sizeof(struct clip_entry);
216 length = file_size - (buf - (unsigned char *) p_voicefile);
218 for (i = 0; i < length; i++)
220 temp = buf[i];
221 temp = ((temp >> 4) & 0x0f) | ((temp & 0x0f) << 4);
222 temp = ((temp >> 2) & 0x33) | ((temp & 0x33) << 2);
223 buf[i] = ((temp >> 1) & 0x55) | ((temp & 0x55) << 1);
225 cpu_boost(false);
227 #endif
229 #ifdef HAVE_MMC
230 /* load the index table, now that we know its size from the header */
231 load_size = (p_voicefile->id1_max + p_voicefile->id2_max)
232 * sizeof(struct clip_entry);
233 got_size = read(filehandle,
234 (unsigned char *) p_voicefile + offsetof(struct voicefile, index), load_size);
235 if (got_size != load_size) /* read error */
236 goto load_err;
237 #else
238 close(filehandle); /* only the MMC variant leaves it open */
239 filehandle = -1;
240 #endif
242 /* make sure to have the silence clip, if available */
243 p_silence = get_clip(VOICE_PAUSE, &silence_len);
245 return;
247 load_err:
248 p_voicefile = NULL;
249 has_voicefile = false; /* don't try again */
250 if (filehandle >= 0)
252 close(filehandle);
253 filehandle = -1;
255 return;
259 /* called in ISR context if mp3 data got consumed */
260 static void mp3_callback(unsigned char** start, int* size)
262 queue[queue_read].len -= sent; /* we completed this */
263 queue[queue_read].buf += sent;
265 if (queue[queue_read].len > 0) /* current clip not finished? */
266 { /* feed the next 64K-1 chunk */
267 #if CONFIG_CODEC != SWCODEC
268 sent = MIN(queue[queue_read].len, 0xFFFF);
269 #else
270 sent = queue[queue_read].len;
271 #endif
272 *start = queue[queue_read].buf;
273 *size = sent;
274 return;
276 else if (sent > 0) /* go to next entry */
278 queue_read = (queue_read + 1) & QUEUE_MASK;
281 re_check:
283 if (QUEUE_LEVEL) /* queue is not empty? */
284 { /* start next clip */
285 #if CONFIG_CODEC != SWCODEC
286 sent = MIN(queue[queue_read].len, 0xFFFF);
287 #else
288 sent = queue[queue_read].len;
289 #endif
290 *start = p_lastclip = queue[queue_read].buf;
291 *size = sent;
292 curr_hd[0] = p_lastclip[1];
293 curr_hd[1] = p_lastclip[2];
294 curr_hd[2] = p_lastclip[3];
296 else if (p_silence != NULL /* silence clip available */
297 && p_lastclip != p_silence /* previous clip wasn't silence */
298 && p_lastclip != p_thumbnail) /* ..or thumbnail */
299 { /* add silence clip when queue runs empty playing a voice clip */
300 queue[queue_write].buf = p_silence;
301 queue[queue_write].len = silence_len;
302 queue_write = (queue_write + 1) & QUEUE_MASK;
304 goto re_check;
306 else
308 *size = 0; /* end of data */
312 /* stop the playback and the pending clips */
313 static int shutup(void)
315 #if CONFIG_CODEC != SWCODEC
316 unsigned char* pos;
317 unsigned char* search;
318 unsigned char* end;
319 #endif
321 if (QUEUE_LEVEL == 0) /* has ended anyway */
323 #if CONFIG_CODEC == SWCODEC
324 mp3_play_stop();
325 #endif
326 return 0;
328 #if CONFIG_CODEC != SWCODEC
329 #if CONFIG_CPU == SH7034
330 CHCR3 &= ~0x0001; /* disable the DMA (and therefore the interrupt also) */
331 #endif
332 /* search next frame boundary and continue up to there */
333 pos = search = mp3_get_pos();
334 end = queue[queue_read].buf + queue[queue_read].len;
336 if (pos >= queue[queue_read].buf
337 && pos <= end) /* really our clip? */
338 { /* (for strange reasons this isn't nesessarily the case) */
339 /* find the next frame boundary */
340 while (search < end) /* search the remaining data */
342 if (*search++ != 0xFF) /* quick search for frame sync byte */
343 continue; /* (this does the majority of the job) */
345 /* look at the (bitswapped) rest of header candidate */
346 if (search[0] == curr_hd[0] /* do the quicker checks first */
347 && search[2] == curr_hd[2]
348 && (search[1] & 0x30) == (curr_hd[1] & 0x30)) /* sample rate */
350 search--; /* back to the sync byte */
351 break; /* From looking at it, this is our header. */
355 if (search-pos)
356 { /* play old data until the frame end, to keep the MAS in sync */
357 sent = search-pos;
359 queue_write = (queue_read + 1) & QUEUE_MASK; /* will be empty after next callback */
360 queue[queue_read].len = sent; /* current one ends after this */
362 #if CONFIG_CPU == SH7034
363 DTCR3 = sent; /* let the DMA finish this frame */
364 CHCR3 |= 0x0001; /* re-enable DMA */
365 #endif
366 return 0;
369 #endif
371 /* nothing to do, was frame boundary or not our clip */
372 mp3_play_stop();
374 queue_write = queue_read = 0; /* reset the queue */
376 return 0;
380 /* schedule a clip, at the end or discard the existing queue */
381 static int queue_clip(unsigned char* buf, long size, bool enqueue)
383 int queue_level;
385 if (!enqueue)
386 shutup(); /* cut off all the pending stuff */
388 if (!size)
389 return 0; /* safety check */
390 #if CONFIG_CPU == SH7034
391 /* disable the DMA temporarily, to be safe of race condition */
392 CHCR3 &= ~0x0001;
393 #endif
394 queue_level = QUEUE_LEVEL; /* check old level */
396 if (queue_level < QUEUE_SIZE - 1) /* space left? */
398 queue[queue_write].buf = buf; /* populate an entry */
399 queue[queue_write].len = size;
400 queue_write = (queue_write + 1) & QUEUE_MASK;
403 if (queue_level == 0)
404 { /* queue was empty, we have to do the initial start */
405 p_lastclip = buf;
406 #if CONFIG_CODEC != SWCODEC
407 sent = MIN(size, 0xFFFF); /* DMA can do no more */
408 #else
409 sent = size;
410 #endif
411 mp3_play_data(buf, sent, mp3_callback);
412 curr_hd[0] = buf[1];
413 curr_hd[1] = buf[2];
414 curr_hd[2] = buf[3];
415 mp3_play_pause(true); /* kickoff audio */
417 else
419 #if CONFIG_CPU == SH7034
420 CHCR3 |= 0x0001; /* re-enable DMA */
421 #endif
424 return 0;
427 /* fetch a clip from the voice file */
428 static unsigned char* get_clip(long id, long* p_size)
430 long clipsize;
431 unsigned char* clipbuf;
433 if (id > VOICEONLY_DELIMITER)
434 { /* voice-only entries use the second part of the table */
435 id -= VOICEONLY_DELIMITER + 1;
436 if (id >= p_voicefile->id2_max)
437 return NULL; /* must be newer than we have */
438 id += p_voicefile->id1_max; /* table 2 is behind table 1 */
440 else
441 { /* normal use of the first table */
442 if (id >= p_voicefile->id1_max)
443 return NULL; /* must be newer than we have */
446 clipsize = p_voicefile->index[id].size;
447 if (clipsize == 0) /* clip not included in voicefile */
448 return NULL;
449 clipbuf = (unsigned char *) p_voicefile + p_voicefile->index[id].offset;
451 #ifdef HAVE_MMC /* dynamic loading, on demand */
452 if (!(clipsize & LOADED_MASK))
453 { /* clip used for the first time, needs loading */
454 lseek(filehandle, p_voicefile->index[id].offset, SEEK_SET);
455 if (read(filehandle, clipbuf, clipsize) != clipsize)
456 return NULL; /* read error */
458 p_voicefile->index[id].size |= LOADED_MASK; /* mark as loaded */
460 else
461 { /* clip is in memory already */
462 clipsize &= ~LOADED_MASK; /* without the extra bit gives true size */
464 #endif
466 *p_size = clipsize;
467 return clipbuf;
471 /* common code for talk_init() and talk_buffer_steal() */
472 static void reset_state(void)
474 queue_write = queue_read = 0; /* reset the queue */
475 p_voicefile = NULL; /* indicate no voicefile (trashed) */
476 #if CONFIG_CODEC == SWCODEC
477 /* Allocate a dedicated thumbnail buffer - once */
478 if (p_thumbnail == NULL)
480 size_for_thumbnail = audiobufend - audiobuf;
481 if (size_for_thumbnail > MAX_THUMBNAIL_BUFSIZE)
482 size_for_thumbnail = MAX_THUMBNAIL_BUFSIZE;
483 p_thumbnail = buffer_alloc(size_for_thumbnail);
485 #else
486 /* Just use the audiobuf, without allocating anything */
487 p_thumbnail = audiobuf;
488 size_for_thumbnail = audiobufend - audiobuf;
489 #endif
490 p_silence = NULL; /* pause clip not accessible */
493 /***************** Public implementation *****************/
495 void talk_init(void)
497 if (talk_initialized && !strcasecmp(last_lang, global_settings.lang_file))
499 /* not a new file, nothing to do */
500 return;
503 #ifdef HAVE_MMC
504 if (filehandle >= 0) /* MMC: An old voice file might still be open */
506 close(filehandle);
507 filehandle = -1;
509 #endif
511 talk_initialized = true;
512 strncpy((char *) last_lang, (char *)global_settings.lang_file,
513 MAX_FILENAME);
515 #if CONFIG_CODEC == SWCODEC
516 audio_get_buffer(false, NULL); /* Must tell audio to reinitialize */
517 #endif
518 reset_state(); /* use this for most of our inits */
520 filehandle = open_voicefile();
521 has_voicefile = (filehandle >= 0); /* test if we can open it */
522 voicefile_size = 0;
524 if (has_voicefile)
526 voicefile_size = filesize(filehandle);
527 #if CONFIG_CODEC == SWCODEC
528 voice_init();
529 #endif
530 close(filehandle); /* close again, this was just to detect presence */
531 filehandle = -1;
536 #if CONFIG_CODEC == SWCODEC
537 /* return if a voice codec is required or not */
538 bool talk_voice_required(void)
540 return (voicefile_size != 0) /* Voice file is available */
541 || (global_settings.talk_dir == 3) /* Thumbnail clips are required */
542 || (global_settings.talk_file == 3);
544 #endif
546 /* return size of voice file */
547 int talk_get_bufsize(void)
549 return voicefile_size;
552 /* somebody else claims the mp3 buffer, e.g. for regular play/record */
553 int talk_buffer_steal(void)
555 #if CONFIG_CODEC != SWCODEC
556 mp3_play_stop();
557 #endif
558 #ifdef HAVE_MMC
559 if (filehandle >= 0) /* only relevant for MMC */
561 close(filehandle);
562 filehandle = -1;
564 #endif
565 reset_state();
567 return 0;
571 /* play a voice ID from voicefile */
572 int talk_id(long id, bool enqueue)
574 long clipsize;
575 unsigned char* clipbuf;
576 int unit;
578 #if CONFIG_CODEC != SWCODEC
579 if (audio_status()) /* busy, buffer in use */
580 return -1;
581 #endif
583 if (p_voicefile == NULL && has_voicefile)
584 load_voicefile(); /* reload needed */
586 if (p_voicefile == NULL) /* still no voices? */
587 return -1;
589 if (id == -1) /* -1 is an indication for silence */
590 return -1;
592 /* check if this is a special ID, with a value */
593 unit = ((unsigned long)id) >> UNIT_SHIFT;
594 if (unit)
595 { /* sign-extend the value */
596 id = (unsigned long)id << (32-UNIT_SHIFT);
597 id >>= (32-UNIT_SHIFT);
598 talk_value(id, unit, enqueue); /* speak it */
599 return 0; /* and stop, end of special case */
602 clipbuf = get_clip(id, &clipsize);
603 if (clipbuf == NULL)
604 return -1; /* not present */
606 queue_clip(clipbuf, clipsize, enqueue);
608 return 0;
612 /* play a thumbnail from file */
613 int talk_file(const char* filename, bool enqueue)
615 int fd;
616 int size;
617 struct mp3entry info;
619 #if CONFIG_CODEC != SWCODEC
620 if (audio_status()) /* busy, buffer in use */
621 return -1;
622 #endif
624 if (p_thumbnail == NULL || size_for_thumbnail <= 0)
625 return -1;
627 if(mp3info(&info, filename, false)) /* use this to find real start */
629 return 0; /* failed to open, or invalid */
632 fd = open(filename, O_RDONLY);
633 if (fd < 0) /* failed to open */
635 return 0;
638 lseek(fd, info.first_frame_offset, SEEK_SET); /* behind ID data */
640 size = read(fd, p_thumbnail, size_for_thumbnail);
641 close(fd);
643 /* ToDo: find audio, skip ID headers and trailers */
645 if (size != 0 && size != size_for_thumbnail) /* Don't play missing or truncated clips */
647 #if CONFIG_CODEC != SWCODEC
648 bitswap(p_thumbnail, size);
649 #endif
650 queue_clip(p_thumbnail, size, enqueue);
653 return size;
657 /* say a numeric value, this word ordering works for english,
658 but not necessarily for other languages (e.g. german) */
659 int talk_number(long n, bool enqueue)
661 int level = 2; /* mille count */
662 long mil = 1000000000; /* highest possible "-illion" */
664 #if CONFIG_CODEC != SWCODEC
665 if (audio_status()) /* busy, buffer in use */
666 return -1;
667 #endif
669 if (!enqueue)
670 shutup(); /* cut off all the pending stuff */
672 if (n==0)
673 { /* special case */
674 talk_id(VOICE_ZERO, true);
675 return 0;
678 if (n<0)
680 talk_id(VOICE_MINUS, true);
681 n = -n;
684 while (n)
686 int segment = n / mil; /* extract in groups of 3 digits */
687 n -= segment * mil; /* remove the used digits from number */
688 mil /= 1000; /* digit place for next round */
690 if (segment)
692 int hundreds = segment / 100;
693 int ones = segment % 100;
695 if (hundreds)
697 talk_id(VOICE_ZERO + hundreds, true);
698 talk_id(VOICE_HUNDRED, true);
701 /* combination indexing */
702 if (ones > 20)
704 int tens = ones/10 + 18;
705 talk_id(VOICE_ZERO + tens, true);
706 ones %= 10;
709 /* direct indexing */
710 if (ones)
711 talk_id(VOICE_ZERO + ones, true);
713 /* add billion, million, thousand */
714 if (mil)
715 talk_id(VOICE_THOUSAND + level, true);
717 level--;
720 return 0;
723 /* singular/plural aware saying of a value */
724 int talk_value(long n, int unit, bool enqueue)
726 int unit_id;
727 static const int unit_voiced[] =
728 { /* lookup table for the voice ID of the units */
729 [0 ... UNIT_LAST-1] = -1, /* regular ID, int, signed */
730 [UNIT_MS]
731 = VOICE_MILLISECONDS, /* here come the "real" units */
732 [UNIT_SEC]
733 = VOICE_SECONDS,
734 [UNIT_MIN]
735 = VOICE_MINUTES,
736 [UNIT_HOUR]
737 = VOICE_HOURS,
738 [UNIT_KHZ]
739 = VOICE_KHZ,
740 [UNIT_DB]
741 = VOICE_DB,
742 [UNIT_PERCENT]
743 = VOICE_PERCENT,
744 [UNIT_MAH]
745 = VOICE_MILLIAMPHOURS,
746 [UNIT_PIXEL]
747 = VOICE_PIXEL,
748 [UNIT_PER_SEC]
749 = VOICE_PER_SEC,
750 [UNIT_HERTZ]
751 = VOICE_HERTZ,
752 [UNIT_MB]
753 = LANG_MEGABYTE,
754 [UNIT_KBIT]
755 = VOICE_KBIT_PER_SEC,
758 #if CONFIG_CODEC != SWCODEC
759 if (audio_status()) /* busy, buffer in use */
760 return -1;
761 #endif
763 if (unit < 0 || unit >= UNIT_LAST)
764 unit_id = -1;
765 else
766 unit_id = unit_voiced[unit];
768 if ((n==1 || n==-1) /* singular? */
769 && unit_id >= VOICE_SECONDS && unit_id <= VOICE_HOURS)
771 unit_id--; /* use the singular for those units which have */
774 /* special case with a "plus" before */
775 if (n > 0 && (unit == UNIT_SIGNED || unit == UNIT_DB))
777 talk_id(VOICE_PLUS, enqueue);
778 enqueue = true;
781 talk_number(n, enqueue); /* say the number */
782 talk_id(unit_id, true); /* say the unit, if any */
784 return 0;
787 /* spell a string */
788 int talk_spell(const char* spell, bool enqueue)
790 char c; /* currently processed char */
792 #if CONFIG_CODEC != SWCODEC
793 if (audio_status()) /* busy, buffer in use */
794 return -1;
795 #endif
797 if (!enqueue)
798 shutup(); /* cut off all the pending stuff */
800 while ((c = *spell++) != '\0')
802 /* if this grows into too many cases, I should use a table */
803 if (c >= 'A' && c <= 'Z')
804 talk_id(VOICE_CHAR_A + c - 'A', true);
805 else if (c >= 'a' && c <= 'z')
806 talk_id(VOICE_CHAR_A + c - 'a', true);
807 else if (c >= '0' && c <= '9')
808 talk_id(VOICE_ZERO + c - '0', true);
809 else if (c == '-')
810 talk_id(VOICE_MINUS, true);
811 else if (c == '+')
812 talk_id(VOICE_PLUS, true);
813 else if (c == '.')
814 talk_id(VOICE_DOT, true);
815 else if (c == ' ')
816 talk_id(VOICE_PAUSE, true);
819 return 0;