From a5985dd55d158ab4deb1cc83d0df0eb9c8ef1cb4 Mon Sep 17 00:00:00 2001 From: vk7js <58905135+vk7js@users.noreply.github.com> Date: Mon, 16 May 2022 21:28:13 +1000 Subject: [PATCH] Added custom dictionary support for common words used in Channel names and contact names (ported from AccessibleGD77). Added 9 custom word prompts. (One unused). --- openrtx/include/core/voicePrompts.h | 16 +++++++++++ openrtx/src/core/voicePrompts.c | 43 +++++++++++++++++++++++++++-- 2 files changed, 56 insertions(+), 3 deletions(-) diff --git a/openrtx/include/core/voicePrompts.h b/openrtx/include/core/voicePrompts.h index a9c97b70..fae8290d 100644 --- a/openrtx/include/core/voicePrompts.h +++ b/openrtx/include/core/voicePrompts.h @@ -151,6 +151,16 @@ PROMPT_BAR, // bar PROMPT_UNDERLINE, // underline PROMPT_CARET, // caret PROMPT_LEFT_BRACE, // left brace +PROMPT_CUSTOM1, // Hotspot +PROMPT_CUSTOM2, // ClearNode +PROMPT_CUSTOM3, // ShariNode +PROMPT_CUSTOM4, // MicroHub +PROMPT_CUSTOM5, // Openspot +PROMPT_CUSTOM6, // repeater +PROMPT_CUSTOM7, // BlindHams +PROMPT_CUSTOM8, // Allstar +PROMPT_CUSTOM9, // parrot +PROMPT_CUSTOM10, // unused NUM_VOICE_PROMPTS, } voicePrompt_t; @@ -204,6 +214,12 @@ typedef enum vpHigh } VoicePromptVerbosity_T; +typedef struct +{ + const char* userWord; + const voicePrompt_t vp; +} userDictEntry; + extern bool vpDataIsLoaded; extern const uint32_t VOICE_PROMPTS_FLASH_HEADER_ADDRESS; extern VoicePromptVerbosity_T vpLevel; diff --git a/openrtx/src/core/voicePrompts.c b/openrtx/src/core/voicePrompts.c index b2d60ee1..63344462 100644 --- a/openrtx/src/core/voicePrompts.c +++ b/openrtx/src/core/voicePrompts.c @@ -78,6 +78,20 @@ static vpSequence_t vpCurrentSequence = uint32_t tableOfContents[VOICE_PROMPTS_TOC_SIZE]; +const userDictEntry userDictionary[]= +{ + {"hotspot", PROMPT_CUSTOM1}, // Hotspot + {"clearnode", PROMPT_CUSTOM2}, // ClearNode + {"sharinode", PROMPT_CUSTOM3}, // ShariNode + {"microhub", PROMPT_CUSTOM4}, // MicroHub + {"openspot", PROMPT_CUSTOM5}, // Openspot + {"repeater", PROMPT_CUSTOM6}, // repeater + {"blindhams", PROMPT_CUSTOM7}, // BlindHams + {"allstar", PROMPT_CUSTOM8}, // Allstar + {"parrot", PROMPT_CUSTOM9}, // Parrot + {"channel",PROMPT_CHANNEL}, + {0, 0} +}; void vpCacheInit(void) { @@ -203,6 +217,23 @@ void vpQueuePrompt(uint16_t prompt) } } +static uint16_t UserDictLookup(char* ptr, int* advanceBy) +{ + if (!ptr || !*ptr) return 0; + + for (int index=0; userDictionary[index].userWord!=0; ++index) + { + int len=strlen(userDictionary[index].userWord); + if (strncasecmp(userDictionary[index].userWord, ptr, len)==0) + { + *advanceBy=len; + return userDictionary[index].vp; + } + } + + return 0; +} + static bool GetSymbolVPIfItShouldBeAnnounced(char symbol, VoicePromptFlags_T flags, voicePrompt_t* vp) { @@ -241,9 +272,15 @@ void vpQueueString(char *promptString, VoicePromptFlags_T flags) while (*promptString != 0) { - voicePrompt_t vp = PROMPT_SILENCE; - - if ((*promptString >= '0') && (*promptString <= '9')) + int advanceBy=0; + voicePrompt_t vp = UserDictLookup(promptString, &advanceBy); + if (vp) + { + vpQueuePrompt(vp); + promptString += advanceBy; + continue; + } + else if ((*promptString >= '0') && (*promptString <= '9')) { vpQueuePrompt(*promptString - '0' + PROMPT_0); }