summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorJörg Hohensohn <hohensoh@rockbox.org>2004-04-04 19:08:44 +0000
committerJörg Hohensohn <hohensoh@rockbox.org>2004-04-04 19:08:44 +0000
commitc8592bac33920c367ae574e76ac7b6b73e0353c3 (patch)
tree05872941fd109f8e7b0cc63f2fadddb31e4aba06 /apps
parentdd264a8c42f1fbe37774d9c13c744a92ea99ce70 (diff)
downloadrockbox-c8592bac33920c367ae574e76ac7b6b73e0353c3.tar.gz
rockbox-c8592bac33920c367ae574e76ac7b6b73e0353c3.zip
Voice UI: option to spell dirs/files, say (known) extension with file number, minor fixes
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4465 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/lang/english.lang216
-rw-r--r--apps/settings.c12
-rw-r--r--apps/settings_menu.c10
-rw-r--r--apps/talk.c32
-rw-r--r--apps/talk.h1
-rw-r--r--apps/tree.c64
6 files changed, 304 insertions, 31 deletions
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index c44d52272a..bdd26ea84c 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -2427,3 +2427,219 @@ eng: ""
2427voice: "folder" 2427voice: "folder"
2428new: 2428new:
2429 2429
2430id: LANG_VOICE_SPELL
2431desc: "talkbox" mode for files+directories
2432eng: "Spell"
2433voice: "Spell"
2434new:
2435
2436id: VOICE_CHAR_A
2437desc: spoken only, for spelling
2438eng: ""
2439voice: "A"
2440new:
2441
2442id: VOICE_CHAR_B
2443desc: spoken only, for spelling
2444eng: ""
2445voice: "B"
2446new:
2447
2448id: VOICE_CHAR_C
2449desc: spoken only, for spelling
2450eng: ""
2451voice: "C"
2452new:
2453
2454id: VOICE_CHAR_D
2455desc: spoken only, for spelling
2456eng: ""
2457voice: "D"
2458new:
2459
2460id: VOICE_CHAR_E
2461desc: spoken only, for spelling
2462eng: ""
2463voice: "E"
2464new:
2465
2466id: VOICE_CHAR_F
2467desc: spoken only, for spelling
2468eng: ""
2469voice: "F"
2470new:
2471
2472id: VOICE_CHAR_G
2473desc: spoken only, for spelling
2474eng: ""
2475voice: "G"
2476new:
2477
2478id: VOICE_CHAR_H
2479desc: spoken only, for spelling
2480eng: ""
2481voice: "H"
2482new:
2483
2484id: VOICE_CHAR_I
2485desc: spoken only, for spelling
2486eng: ""
2487voice: "I"
2488new:
2489
2490id: VOICE_CHAR_J
2491desc: spoken only, for spelling
2492eng: ""
2493voice: "J"
2494new:
2495
2496id: VOICE_CHAR_K
2497desc: spoken only, for spelling
2498eng: ""
2499voice: "K"
2500new:
2501
2502id: VOICE_CHAR_L
2503desc: spoken only, for spelling
2504eng: ""
2505voice: "L"
2506new:
2507
2508id: VOICE_CHAR_M
2509desc: spoken only, for spelling
2510eng: ""
2511voice: "M"
2512new:
2513
2514id: VOICE_CHAR_N
2515desc: spoken only, for spelling
2516eng: ""
2517voice: "N"
2518new:
2519
2520id: VOICE_CHAR_O
2521desc: spoken only, for spelling
2522eng: ""
2523voice: "O"
2524new:
2525
2526id: VOICE_CHAR_P
2527desc: spoken only, for spelling
2528eng: ""
2529voice: "P"
2530new:
2531
2532id: VOICE_CHAR_Q
2533desc: spoken only, for spelling
2534eng: ""
2535voice: "Q"
2536new:
2537
2538id: VOICE_CHAR_R
2539desc: spoken only, for spelling
2540eng: ""
2541voice: "R"
2542new:
2543
2544id: VOICE_CHAR_S
2545desc: spoken only, for spelling
2546eng: ""
2547voice: "S"
2548new:
2549
2550id: VOICE_CHAR_T
2551desc: spoken only, for spelling
2552eng: ""
2553voice: "T"
2554new:
2555
2556id: VOICE_CHAR_U
2557desc: spoken only, for spelling
2558eng: ""
2559voice: "U"
2560new:
2561
2562id: VOICE_CHAR_V
2563desc: spoken only, for spelling
2564eng: ""
2565voice: "V"
2566new:
2567
2568id: VOICE_CHAR_W
2569desc: spoken only, for spelling
2570eng: ""
2571voice: "W"
2572new:
2573
2574id: VOICE_CHAR_X
2575desc: spoken only, for spelling
2576eng: ""
2577voice: "X"
2578new:
2579
2580id: VOICE_CHAR_Y
2581desc: spoken only, for spelling
2582eng: ""
2583voice: "Y"
2584new:
2585
2586id: VOICE_CHAR_Z
2587desc: spoken only, for spelling
2588eng: ""
2589voice: "Z"
2590new:
2591
2592id: VOICE_EXT_MPA
2593desc: spoken only, for file extension
2594eng: ""
2595voice: "audio"
2596new:
2597
2598id: VOICE_EXT_CFG
2599desc: spoken only, for file extension
2600eng: ""
2601voice: "configuration"
2602new:
2603
2604id: VOICE_EXT_WPS
2605desc: spoken only, for file extension
2606eng: ""
2607voice: "while-playing-screen"
2608new:
2609
2610id: VOICE_EXT_TXT
2611desc: spoken only, for file extension
2612eng: ""
2613voice: "text"
2614new:
2615
2616id: VOICE_EXT_ROCK
2617desc: spoken only, for file extension
2618eng: ""
2619voice: "plug-in"
2620new:
2621
2622id: VOICE_EXT_FONT
2623desc: spoken only, for file extension
2624eng: ""
2625voice: "font"
2626new:
2627
2628id: VOICE_EXT_BMARK
2629desc: spoken only, for file extension
2630eng: ""
2631voice: "bookmark"
2632new:
2633
2634id: VOICE_EXT_UCL
2635desc: spoken only, for file extension
2636eng: ""
2637voice: "flash"
2638new:
2639
2640id: VOICE_EXT_AJZ
2641desc: spoken only, for file extension
2642eng: ""
2643voice: "firmware"
2644new:
2645
diff --git a/apps/settings.c b/apps/settings.c
index a9691f3a6a..2e1a664286 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -1203,13 +1203,13 @@ bool settings_load_config(char* file)
1203 } 1203 }
1204 else if (!strcasecmp(name, "talk dir")) 1204 else if (!strcasecmp(name, "talk dir"))
1205 { 1205 {
1206 static char* options[] = {"off", "number", "enter", "hover"}; 1206 static char* options[] = {"off", "number", "spell", "enter", "hover"};
1207 set_cfg_option(&global_settings.talk_dir, value, options, 4); 1207 set_cfg_option(&global_settings.talk_dir, value, options, 5);
1208 } 1208 }
1209 else if (!strcasecmp(name, "talk file")) 1209 else if (!strcasecmp(name, "talk file"))
1210 { 1210 {
1211 static char* options[] = {"off", "number"}; 1211 static char* options[] = {"off", "number", "spell"};
1212 set_cfg_option(&global_settings.talk_dir, value, options, 2); 1212 set_cfg_option(&global_settings.talk_file, value, options, 3);
1213 } 1213 }
1214 else if (!strcasecmp(name, "talk menu")) 1214 else if (!strcasecmp(name, "talk menu"))
1215 { 1215 {
@@ -1563,11 +1563,11 @@ bool settings_save_config(void)
1563 } 1563 }
1564 fprintf(fd, "#\r\n# Voice\r\n#\r\n"); 1564 fprintf(fd, "#\r\n# Voice\r\n#\r\n");
1565 { 1565 {
1566 static char* options[] = {"off", "number", "enter", "hover"}; 1566 static char* options[] = {"off", "number", "spell", "enter", "hover"};
1567 fprintf(fd, "talk dir: %s\r\n", 1567 fprintf(fd, "talk dir: %s\r\n",
1568 options[global_settings.talk_dir]); 1568 options[global_settings.talk_dir]);
1569 fprintf(fd, "talk file: %s\r\n", /* recycle the options, */ 1569 fprintf(fd, "talk file: %s\r\n", /* recycle the options, */
1570 options[global_settings.talk_file]); /* first 2 are alike */ 1570 options[global_settings.talk_file]); /* first 3 are alike */
1571 fprintf(fd, "talk menu: %s\r\n", 1571 fprintf(fd, "talk menu: %s\r\n",
1572 boolopt[global_settings.talk_menu]); 1572 boolopt[global_settings.talk_menu]);
1573 } 1573 }
diff --git a/apps/settings_menu.c b/apps/settings_menu.c
index a0f039b9a0..6cdf2626e0 100644
--- a/apps/settings_menu.c
+++ b/apps/settings_menu.c
@@ -891,21 +891,23 @@ static bool voice_dirs(void)
891 struct opt_items names[] = { 891 struct opt_items names[] = {
892 { STR(LANG_OFF) }, 892 { STR(LANG_OFF) },
893 { STR(LANG_VOICE_NUMBER) }, 893 { STR(LANG_VOICE_NUMBER) },
894 { STR(LANG_VOICE_SPELL) },
894 { STR(LANG_VOICE_DIR_ENTER) }, 895 { STR(LANG_VOICE_DIR_ENTER) },
895 { STR(LANG_VOICE_DIR_HOVER) } 896 { STR(LANG_VOICE_DIR_HOVER) }
896 }; 897 };
897 return set_option( str(LANG_VOICE_DIR), 898 return set_option( str(LANG_VOICE_DIR),
898 &global_settings.talk_dir, INT, names, 4, NULL); 899 &global_settings.talk_dir, INT, names, 5, NULL);
899} 900}
900 901
901static bool voice_files(void) 902static bool voice_files(void)
902{ 903{
903 struct opt_items names[] = { 904 struct opt_items names[] = {
904 { STR(LANG_OFF) }, 905 { STR(LANG_OFF) },
905 { STR(LANG_VOICE_NUMBER) } 906 { STR(LANG_VOICE_NUMBER) },
907 { STR(LANG_VOICE_SPELL) }
906 }; 908 };
907 return set_option( str(LANG_VOICE_DIR), 909 return set_option( str(LANG_VOICE_FILE),
908 &global_settings.talk_file, INT, names, 2, NULL); 910 &global_settings.talk_file, INT, names, 3, NULL);
909} 911}
910 912
911static bool voice_menu(void) 913static bool voice_menu(void)
diff --git a/apps/talk.c b/apps/talk.c
index 7ba858b47d..a0c730cbcc 100644
--- a/apps/talk.c
+++ b/apps/talk.c
@@ -35,7 +35,7 @@ extern void bitswap(unsigned char *data, int length); /* no header for this */
35 35
36/***************** Constants *****************/ 36/***************** Constants *****************/
37 37
38#define QUEUE_SIZE 20 38#define QUEUE_SIZE 50
39const char* voicefont_file = "/.rockbox/langs/english.voice"; 39const char* voicefont_file = "/.rockbox/langs/english.voice";
40const char* dir_thumbnail_name = ".dirname.mp3"; 40const char* dir_thumbnail_name = ".dirname.mp3";
41 41
@@ -487,3 +487,33 @@ int talk_value(int n, int unit, bool enqueue)
487 return 0; 487 return 0;
488} 488}
489 489
490/* spell a string */
491int talk_spell(char* spell, bool enqueue)
492{
493 char c; /* currently processed char */
494
495 if (mpeg_status()) /* busy, buffer in use */
496 return -1;
497
498 if (!enqueue)
499 shutup(); /* cut off all the pending stuff */
500
501 while ((c = *spell++) != '\0')
502 {
503 /* if this grows into too many cases, I should use a table */
504 if (c >= 'A' && c <= 'Z')
505 talk_id(VOICE_CHAR_A + c - 'A', true);
506 else if (c >= 'a' && c <= 'z')
507 talk_id(VOICE_CHAR_A + c - 'a', true);
508 else if (c >= '0' && c <= '9')
509 talk_id(VOICE_ZERO + c - '0', true);
510 else if (c == '-')
511 talk_id(VOICE_MINUS, true);
512 else if (c == '+')
513 talk_id(VOICE_PLUS, true);
514 else if (c == '.')
515 talk_id(VOICE_POINT, true);
516 }
517
518 return 0;
519}
diff --git a/apps/talk.h b/apps/talk.h
index f3c1366bb0..51504c1a7c 100644
--- a/apps/talk.h
+++ b/apps/talk.h
@@ -64,5 +64,6 @@ int talk_id(int id, bool enqueue); /* play a voice ID from voicefont */
64int talk_file(char* filename, bool enqueue); /* play a thumbnail from file */ 64int talk_file(char* filename, bool enqueue); /* play a thumbnail from file */
65int talk_number(int n, bool enqueue); /* say a number */ 65int talk_number(int n, bool enqueue); /* say a number */
66int talk_value(int n, int unit, bool enqueue); /* say a numeric value */ 66int talk_value(int n, int unit, bool enqueue); /* say a numeric value */
67int talk_spell(char* spell, bool enqueue); /* spell a string */
67 68
68#endif /* __TALK_H__ */ 69#endif /* __TALK_H__ */
diff --git a/apps/tree.c b/apps/tree.c
index 8bd21bb6a4..01aabf7d82 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -70,32 +70,33 @@ static struct
70 char* extension; /* extension for which the file type is recognized */ 70 char* extension; /* extension for which the file type is recognized */
71 int tree_attr; /* which identifier */ 71 int tree_attr; /* which identifier */
72 int icon; /* the icon which shall be used for it, -1 if unknown */ 72 int icon; /* the icon which shall be used for it, -1 if unknown */
73 int voiceclip; /* spoken extension */
73 /* To have it extendable, there could be more useful stuff in here, 74 /* To have it extendable, there could be more useful stuff in here,
74 like handler functions, plugin name, etc. */ 75 like handler functions, plugin name, etc. */
75} filetypes[] = { 76} filetypes[] = {
76 { ".mp3", TREE_ATTR_MPA, File }, 77 { ".mp3", TREE_ATTR_MPA, File, VOICE_EXT_MPA },
77 { ".mp2", TREE_ATTR_MPA, File }, 78 { ".mp2", TREE_ATTR_MPA, File, VOICE_EXT_MPA },
78 { ".mpa", TREE_ATTR_MPA, File }, 79 { ".mpa", TREE_ATTR_MPA, File, VOICE_EXT_MPA },
79 { ".m3u", TREE_ATTR_M3U, Playlist }, 80 { ".m3u", TREE_ATTR_M3U, Playlist, LANG_PLAYINDICES_PLAYLIST },
80 { ".cfg", TREE_ATTR_CFG, Config }, 81 { ".cfg", TREE_ATTR_CFG, Config, VOICE_EXT_CFG },
81 { ".wps", TREE_ATTR_WPS, Wps, }, 82 { ".wps", TREE_ATTR_WPS, Wps, VOICE_EXT_WPS },
82 { ".txt", TREE_ATTR_TXT, Text }, 83 { ".txt", TREE_ATTR_TXT, Text, VOICE_EXT_TXT },
83 { ".lng", TREE_ATTR_LNG, Language }, 84 { ".lng", TREE_ATTR_LNG, Language, LANG_LANGUAGE },
84 { ".rock",TREE_ATTR_ROCK,Plugin }, 85 { ".rock",TREE_ATTR_ROCK,Plugin, VOICE_EXT_ROCK },
85#ifdef HAVE_LCD_BITMAP 86#ifdef HAVE_LCD_BITMAP
86 { ".fnt", TREE_ATTR_FONT,Font }, 87 { ".fnt", TREE_ATTR_FONT,Font, VOICE_EXT_FONT },
87 { ".ch8", TREE_ATTR_CH8, Chip8 }, 88 { ".ch8", TREE_ATTR_CH8, Chip8, -1 },
88 { ".rvf", TREE_ATTR_RVF, Video }, 89 { ".rvf", TREE_ATTR_RVF, Video, -1 },
89 { ".bmark",TREE_ATTR_BMARK,Bookmark }, 90 { ".bmark",TREE_ATTR_BMARK, Bookmark, VOICE_EXT_BMARK },
90#else 91#else
91 { ".bmark", TREE_ATTR_BMARK, -1 }, 92 { ".bmark", TREE_ATTR_BMARK, -1, VOICE_EXT_BMARK },
92#endif 93#endif
93#ifndef SIMULATOR 94#ifndef SIMULATOR
94#ifdef HAVE_LCD_BITMAP 95#ifdef HAVE_LCD_BITMAP
95 { ".ucl", TREE_ATTR_UCL, Flashfile}, 96 { ".ucl", TREE_ATTR_UCL, Flashfile, VOICE_EXT_UCL },
96 { ".ajz", TREE_ATTR_MOD, Mod_Ajz }, 97 { ".ajz", TREE_ATTR_MOD, Mod_Ajz, VOICE_EXT_AJZ },
97#else 98#else
98 { ".mod", TREE_ATTR_MOD, Mod_Ajz }, 99 { ".mod", TREE_ATTR_MOD, Mod_Ajz, VOICE_EXT_AJZ },
99#endif 100#endif
100#endif /* #ifndef SIMULATOR */ 101#endif /* #ifndef SIMULATOR */
101}; 102};
@@ -195,7 +196,7 @@ extern unsigned char bitmap_icons_6x8[LastIcon][6];
195#endif /* HAVE_RECORDER_KEYPAD */ 196#endif /* HAVE_RECORDER_KEYPAD */
196 197
197/* talkbox hovering delay, to avoid immediate disk activity */ 198/* talkbox hovering delay, to avoid immediate disk activity */
198#define HOVER_DELAY (HZ) 199#define HOVER_DELAY (HZ/2)
199 200
200static int build_playlist(int start_index) 201static int build_playlist(int start_index)
201{ 202{
@@ -1061,7 +1062,7 @@ static bool dirbrowse(char *root, int *dirfilter)
1061 snprintf(buf,sizeof(buf),"/%s",file->name); 1062 snprintf(buf,sizeof(buf),"/%s",file->name);
1062 1063
1063 if (file->attr & ATTR_DIRECTORY) { 1064 if (file->attr & ATTR_DIRECTORY) {
1064 if (global_settings.talk_dir == 2) /* enter */ 1065 if (global_settings.talk_dir == 3) /* enter */
1065 { 1066 {
1066 /* play_dirname */ 1067 /* play_dirname */
1067 DEBUGF("Playing directory thumbnail: %s", currdir); 1068 DEBUGF("Playing directory thumbnail: %s", currdir);
@@ -1493,7 +1494,7 @@ static bool dirbrowse(char *root, int *dirfilter)
1493 if (dircache[i].attr & ATTR_DIRECTORY) /* directory? */ 1494 if (dircache[i].attr & ATTR_DIRECTORY) /* directory? */
1494 { 1495 {
1495 /* play directory thumbnail */ 1496 /* play directory thumbnail */
1496 if (global_settings.talk_dir == 3) /* hover */ 1497 if (global_settings.talk_dir == 4) /* hover */
1497 { /* "schedule" a thumbnail, to have a little dalay */ 1498 { /* "schedule" a thumbnail, to have a little dalay */
1498 thumbnail_time = current_tick + HOVER_DELAY; 1499 thumbnail_time = current_tick + HOVER_DELAY;
1499 } 1500 }
@@ -1502,12 +1503,35 @@ static bool dirbrowse(char *root, int *dirfilter)
1502 talk_id(VOICE_DIR, false); 1503 talk_id(VOICE_DIR, false);
1503 talk_number(i+1, true); 1504 talk_number(i+1, true);
1504 } 1505 }
1506 else if (global_settings.talk_dir == 2) /* dirs spelled */
1507 {
1508 talk_spell(dircache[i].name, false);
1509 }
1505 } 1510 }
1506 else if (global_settings.talk_file == 1) /* files as numbers */ 1511 else if (global_settings.talk_file == 1) /* files as numbers */
1507 { 1512 {
1513 /* try to find a voice ID for the extension, if known */
1514 int j;
1515 int ext_id = -1; /* default to none */
1516 for (j=0; j<sizeof(filetypes)/sizeof(*filetypes); j++)
1517 {
1518 if ((dircache[i].attr & TREE_ATTR_MASK) == filetypes[j].tree_attr)
1519 {
1520 ext_id = filetypes[j].voiceclip;
1521 break;
1522 }
1523 }
1524
1508 /* enqueue_next is true if still talking the dir name */ 1525 /* enqueue_next is true if still talking the dir name */
1509 talk_id(VOICE_FILE, enqueue_next); 1526 talk_id(VOICE_FILE, enqueue_next);
1510 talk_number(i-dirsindir+1, true); 1527 talk_number(i-dirsindir+1, true);
1528 talk_id(ext_id, true);
1529 enqueue_next = false;
1530 }
1531 else if (global_settings.talk_file == 2) /* files spelled */
1532 {
1533 /* enqueue_next is true if still talking the dir name */
1534 talk_spell(dircache[i].name, enqueue_next);
1511 enqueue_next = false; 1535 enqueue_next = false;
1512 } 1536 }
1513 1537