diff --git a/openrtx/include/core/voicePrompts.h b/openrtx/include/core/voicePrompts.h index a096bf80..c552096d 100644 --- a/openrtx/include/core/voicePrompts.h +++ b/openrtx/include/core/voicePrompts.h @@ -29,7 +29,6 @@ in the voicePrompts generator project. typedef enum { PROMPT_SILENCE, // -PROMPT_POINT, // POINT PROMPT_0, // 0 PROMPT_1, // 1 PROMPT_2, // 2 @@ -104,18 +103,19 @@ PROMPT_VOLTS, // Volts PROMPT_MILLIWATTS, // Milliwatts PROMPT_WATT, // Wattt PROMPT_WATTS, // Watts -PROMPT_PERCENT, // Percent PROMPT_RECEIVE, // Receive PROMPT_TRANSMIT, // Transmit PROMPT_MODE, // Mode PROMPT_DMR, // D M R PROMPT_FM, // F M PROMPT_M17, // M seventeen +PROMPT_SPACE, // space +PROMPT_PERCENT, // Percent +PROMPT_POINT, // POINT PROMPT_PLUS, // Plus PROMPT_MINUS, // Minus PROMPT_STAR, // Star PROMPT_HASH, // Hash -PROMPT_SPACE, // space PROMPT_EXCLAIM, // exclaim PROMPT_COMMA, // comma PROMPT_AT, // at @@ -142,13 +142,18 @@ NUM_VOICE_PROMPTS, __MAKE_ENUM_16BITS = INT16_MAX } voicePrompt_t; +// PROMPT_VOICE_NAME is always the very last prompt after the indexed prompts from the strings table. #define PROMPT_VOICE_NAME (NUM_VOICE_PROMPTS + (sizeof(stringsTable_t)/sizeof(char*))) + typedef enum { vpAnnounceCaps=0x01, vpAnnounceCustomPrompts=0x02, - vpAnnounceSpaceAndSymbols=0x04, - vpAnnouncePhoneticRendering=0x08, + vpAnnounceSpace=0x04, + vpAnnounceCommonSymbols=0x08, + vpAnnounceLessCommonSymbols=0x10, + vpAnnounceASCIIValueForUnknownChars=0x20, + vpAnnouncePhoneticRendering=0x40, } VoicePromptFlags_T; extern bool voicePromptDataIsLoaded; diff --git a/openrtx/src/core/voicePrompts.c b/openrtx/src/core/voicePrompts.c index 2b14e845..c78f8060 100644 --- a/openrtx/src/core/voicePrompts.c +++ b/openrtx/src/core/voicePrompts.c @@ -188,11 +188,16 @@ void vpQueuePrompt(uint16_t prompt) // This function spells out a string letter by letter. void vpQueueString(char *promptString, VoicePromptFlags_T flags) { - const char indexedSymbols[] = "!,@:?()~/[]<>=$'`&|_^{}"; // handles most of them in indexed order, must match order of vps. + const char indexedSymbols[] = "%.+-*#!,@:?()~/[]<>=$'`&|_^{}"; // handles must match order of vps. + const char commonSymbols[] = "%.+-*#"; // handles must match order of vps. + if (voicePromptIsActive) { vpInit(); } + bool announceCommonSymbols = (flags & vpAnnounceCommonSymbols) ? true : false; + bool announceLessCommonSymbols=(flags & vpAnnounceLessCommonSymbols) ? true : false; + while (*promptString != 0) { if ((*promptString >= '0') && (*promptString <= '9')) @@ -215,52 +220,42 @@ void vpQueueString(char *promptString, VoicePromptFlags_T flags) else vpQueuePrompt(*promptString - 'a' + PROMPT_A); } - else if (*promptString == '.') + else if ((*promptString==' ') && (flags&vpAnnounceSpace)) { - vpQueuePrompt(PROMPT_POINT); + vpQueuePrompt(PROMPT_SPACE); } - else if (*promptString == '+') + else if (announceCommonSymbols || announceLessCommonSymbols) { - vpQueuePrompt(PROMPT_PLUS); - } - else if (*promptString == '-') - { - vpQueuePrompt(PROMPT_MINUS); - } - else if (*promptString == '%') - { - vpQueuePrompt(PROMPT_PERCENT); - } - else if (*promptString == '*') - { - vpQueuePrompt(PROMPT_STAR); - } - else if (*promptString == '#') - { - vpQueuePrompt(PROMPT_HASH); - } - else if (flags&(vpAnnounceSpaceAndSymbols)) - { - if (*promptString==' ') - vpQueuePrompt(PROMPT_SPACE); - else + char* symbolPtr = strchr(indexedSymbols, *promptString); + if (symbolPtr != NULL) { - char* ptr=strchr(indexedSymbols, *promptString); - if (ptr) + bool commonSymbol= strchr(commonSymbols, *symbolPtr) != NULL; + + if ((commonSymbol && announceCommonSymbols) || (!commonSymbol && announceLessCommonSymbols)) { - vpQueuePrompt(PROMPT_EXCLAIM+(ptr-indexedSymbols)); + vpQueuePrompt(PROMPT_PERCENT+(symbolPtr-indexedSymbols)); } else { - int32_t val = *promptString; - vpQueueLanguageString(¤tLanguage->dtmf_code); // just the word "code" as we don't have character. - vpQueueInteger(val); + vpQueuePrompt(PROMPT_SILENCE); } } + else if (flags&vpAnnounceASCIIValueForUnknownChars) + { + int32_t val = *promptString; + vpQueueLanguageString(¤tLanguage->dtmf_code); // just the word "code" as we don't have character. + vpQueueInteger(val); + } + else + { + vpQueuePrompt(PROMPT_SILENCE); + } } else + { // otherwise just add silence vpQueuePrompt(PROMPT_SILENCE); + } promptString++; }