Skip to content

Commit

Permalink
fix: Plurals and indefinite articles in German TTS, plus (#3920)
Browse files Browse the repository at this point in the history
- fixed no LUA constant for unit dbm
- fixed use plurals and indefinite articles in German TTS
  • Loading branch information
mha1 authored and pfeerick committed Oct 27, 2023
1 parent 08e2b5e commit 5ba8fc4
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
2 changes: 1 addition & 1 deletion radio/src/audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ const char * const unitsFilenames[] = {
"rpm",
"g",
"degree",
"radian",
"rad",
"ml",
"founce",
"mlpm",
Expand Down
1 change: 1 addition & 0 deletions radio/src/lua/api_general.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3185,6 +3185,7 @@ LROT_BEGIN(etxcst, NULL, 0)
LROT_NUMENTRY( UNIT_HERTZ, UNIT_HERTZ )
LROT_NUMENTRY( UNIT_MS, UNIT_MS )
LROT_NUMENTRY( UNIT_US, UNIT_US )
LROT_NUMENTRY( UNIT_DBM, UNIT_DBM )
LROT_NUMENTRY( UNIT_HOURS, UNIT_HOURS )
LROT_NUMENTRY( UNIT_MINUTES, UNIT_MINUTES )
LROT_NUMENTRY( UNIT_SECONDS, UNIT_SECONDS )
Expand Down
36 changes: 30 additions & 6 deletions radio/src/translations/tts_de.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,23 @@ enum GermanPrompts {

};

#define DE_PUSH_UNIT_PROMPT(u) de_pushUnitPrompt((u), id)
#define DE_PUSH_UNIT_PROMPT(u, p) de_pushUnitPrompt((u), (p), id)

I18N_PLAY_FUNCTION(de, pushUnitPrompt, uint8_t unitprompt)
I18N_PLAY_FUNCTION(de, pushUnitPrompt, uint8_t unitprompt, int16_t number)
{
PUSH_UNIT_PROMPT(unitprompt, 0);
if(number != 1 && // do plurals for this list of units if number is not 1
(unitprompt == UNIT_HOURS ||
unitprompt == UNIT_MINUTES ||
unitprompt == UNIT_SECONDS ||
unitprompt == UNIT_FLOZ ||
unitprompt == UNIT_MS ||
unitprompt == UNIT_US ||
unitprompt == UNIT_RADIANS ||
unitprompt == UNIT_MAH)) {
PUSH_UNIT_PROMPT(unitprompt, 1); // push xxx1.wav for plural version
}
else
PUSH_UNIT_PROMPT(unitprompt, 0); // push xxx0.wav for singular version
}

I18N_PLAY_FUNCTION(de, playNumber, getvalue_t number, uint8_t unit, uint8_t att)
Expand Down Expand Up @@ -109,10 +121,12 @@ I18N_PLAY_FUNCTION(de, playNumber, getvalue_t number, uint8_t unit, uint8_t att)
}
}
if(unit)
DE_PUSH_UNIT_PROMPT(unit);
DE_PUSH_UNIT_PROMPT(unit, qr.quot);
return;
}

int16_t tmp = number;

if (number >= 2000) {
PLAY_NUMBER(number / 1000, 0, 0);
PUSH_NUMBER_PROMPT(DE_PROMPT_TAUSEND);
Expand Down Expand Up @@ -146,11 +160,21 @@ I18N_PLAY_FUNCTION(de, playNumber, getvalue_t number, uint8_t unit, uint8_t att)
}

if (number >= 0) {
PUSH_NUMBER_PROMPT(DE_PROMPT_NULL + number / 1);
if(number == 1) {
if(unit == UNIT_HOURS ||
unit == UNIT_MINUTES ||
unit == UNIT_SECONDS ||
unit == UNIT_FLOZ ||
unit == UNIT_MS ||
unit == UNIT_US ||
unit == UNIT_MAH)
PUSH_NUMBER_PROMPT(DE_PROMPT_EINE); // "eine ..."
} else
PUSH_NUMBER_PROMPT(DE_PROMPT_NULL + number / 1); // "ein ...""
}

if (unit) {
DE_PUSH_UNIT_PROMPT(unit);
DE_PUSH_UNIT_PROMPT(unit, tmp);
}
}

Expand Down

0 comments on commit 5ba8fc4

Please sign in to comment.