Proposal to fix #4831 (CZ TTS problem with PREC1 and units) (#4856)

* Proposal to fix #4831

* Next fix for #4831

* Initiate some CZ docs

* Some more structure, still a workframe

* My attempt to help with #4831

* Update tts_doc_cz.md

* copy/paste error

* Update tts_doc_cz.md

* missed one number/qr.quot

* Cosmetics

* Consistency in parameters order

* Nearly complete doc

* Cosmetics to facilitate coding for non CZ devs

* Fix integer+unit, cosmetics

* Update tts_doc Radians and Mililiters are Male gender

* Radian and Millimeter are Male (so i've been told)

* Cosmetics

* Invers pushUnitPrompt parameters as per bsongis request
This commit is contained in:
Bertrand Songis
2017-04-26 21:42:01 +02:00
committed by GitHub
parent c15922a942
commit f10bad7abe
9 changed files with 206 additions and 139 deletions
+67 -84
View File
@@ -24,9 +24,9 @@
enum CzechPrompts {
CZ_PROMPT_NUMBERS_BASE = 0,
CZ_PROMPT_NULA = CZ_PROMPT_NUMBERS_BASE+0, //0-99
CZ_PROMPT_STO = CZ_PROMPT_NUMBERS_BASE+100, //100,200 .. 900
CZ_PROMPT_TISIC = CZ_PROMPT_NUMBERS_BASE+109, //1000
CZ_PROMPT_NULA = CZ_PROMPT_NUMBERS_BASE+0, // 0-99
CZ_PROMPT_STO = CZ_PROMPT_NUMBERS_BASE+100, // 100,200 .. 900
CZ_PROMPT_TISIC = CZ_PROMPT_NUMBERS_BASE+109, // 1000
CZ_PROMPT_TISICE = CZ_PROMPT_NUMBERS_BASE+110,
CZ_PROMPT_JEDEN = CZ_PROMPT_NUMBERS_BASE+111,
CZ_PROMPT_JEDNO = CZ_PROMPT_NUMBERS_BASE+112,
@@ -36,45 +36,44 @@ enum CzechPrompts {
CZ_PROMPT_CELYCH = CZ_PROMPT_NUMBERS_BASE+116,
CZ_PROMPT_MINUS = CZ_PROMPT_NUMBERS_BASE+117,
CZ_PROMPT_UNITS_BASE = 118, //(jeden)volt,(dva)volty,(pet)voltu,(desetina)voltu
CZ_PROMPT_UNITS_BASE = 118, // (jeden)volt,(dva)volty,(pet)voltu,(desetina)voltu
};
#if defined(VOICE)
#if defined(CPUARM)
#define CZ_PUSH_UNIT_PROMPT(p, u) cz_pushUnitPrompt((p), (u), id)
#define CZ_PUSH_UNIT_PROMPT(u, p) cz_pushUnitPrompt((u), (p), id)
#else
#define CZ_PUSH_UNIT_PROMPT(p, u) pushUnitPrompt((p), (u))
#define CZ_PUSH_UNIT_PROMPT(u, p) pushUnitPrompt((u), (p))
#endif
#define MUZSKY 0x80
#define ZENSKY 0x81
#define STREDNI 0x82
#define MALE 0x80
#define FEMALE 0x81
#define NEUTRAL 0x82
I18N_PLAY_FUNCTION(cz, pushUnitPrompt, int16_t number, uint8_t unitprompt)
I18N_PLAY_FUNCTION(cz, pushUnitPrompt, uint8_t unit, int16_t number)
{
#if defined(CPUARM)
TRACE("CZSAY unit:%d number:%d", unit, number);
if (number == 1)
PUSH_UNIT_PROMPT(unitprompt, 0);
PUSH_UNIT_PROMPT(unit, 0);
else if (number > 1 && number < 5)
PUSH_UNIT_PROMPT(unitprompt, 1);
PUSH_UNIT_PROMPT(unit, 1);
else
PUSH_UNIT_PROMPT(unitprompt, 2);
PUSH_UNIT_PROMPT(unit, 2);
#else
unitprompt = CZ_PROMPT_UNITS_BASE+((unitprompt-1)*4);
unitprompt = CZ_PROMPT_UNITS_BASE+((unit-1)*4);
if (number == 1)
PUSH_NUMBER_PROMPT(unitprompt);
PUSH_NUMBER_PROMPT(unit);
else if (number > 1 && number < 5)
PUSH_NUMBER_PROMPT(unitprompt+1);
PUSH_NUMBER_PROMPT(unit+1);
else
PUSH_NUMBER_PROMPT(unitprompt+2);
PUSH_NUMBER_PROMPT(unit+2);
#endif
}
I18N_PLAY_FUNCTION(cz, playNumber, getvalue_t number, uint8_t unit, uint8_t att)
{
if (number < 0) {
PUSH_NUMBER_PROMPT(CZ_PROMPT_MINUS);
number = -number;
@@ -105,88 +104,72 @@ I18N_PLAY_FUNCTION(cz, playNumber, getvalue_t number, uint8_t unit, uint8_t att)
#else
// we assume that we are PREC1
#endif
div_t qr = div((int)number, 10);
if (qr.rem) {
PLAY_NUMBER(qr.quot, 0, ZENSKY);
if (qr.quot == 0)
PUSH_NUMBER_PROMPT(CZ_PROMPT_CELA);
else
CZ_PUSH_UNIT_PROMPT(qr.quot, CZ_PROMPT_CELA);
PLAY_NUMBER(qr.rem, 0, ZENSKY);
PUSH_NUMBER_PROMPT(CZ_PROMPT_UNITS_BASE+((unit-1)*4)+3);
return;
div_t qr = div((int)number, 10);
if (qr.rem) {
PLAY_NUMBER(qr.quot, 0, FEMALE);
if (qr.quot < 2) {
PUSH_NUMBER_PROMPT(CZ_PROMPT_CELA);
}
else
number = qr.quot;
else if (qr.quot > 1 && qr.quot < 5) {
PUSH_NUMBER_PROMPT(CZ_PROMPT_CELE);
}
else {
PUSH_NUMBER_PROMPT(CZ_PROMPT_CELYCH);
};
PLAY_NUMBER(qr.rem, 0, FEMALE);
#if defined(CPUARM)
PUSH_UNIT_PROMPT(unit, 3);
#else
PUSH_NUMBER_PROMPT(CZ_PROMPT_UNITS_BASE+((unit-1)*4)+3);
#endif
return;
}
else {
number = qr.quot;
}
}
int16_t tmp = number;
#if defined(CPUARM)
switch(unit) {
case 0:
case UNIT_RAW:
break;
case 6:
case 8:
case 10:
case 14:
case 18:
case 21:
case 22:
case 23:
case 24:
case 25:
case 26:
att = ZENSKY;
case UNIT_FEET_PER_SECOND:
case UNIT_MPH:
case UNIT_FEET:
case UNIT_MAH:
case UNIT_RPMS:
case UNIT_FLOZ:
case UNIT_HOURS:
case UNIT_MINUTES:
case UNIT_SECONDS:
att = FEMALE;
break;
case 13:
case 19:
att = STREDNI;
case UNIT_PERCENT:
case UNIT_G:
att = NEUTRAL;
break;
default:
att = MUZSKY;
att = MALE;
break;
}
#else
switch(unit) {
case 0:
break;
case 4:
case 10:
case 13:
case 14:
case 15:
case 16:
case 17:
case 18:
att = ZENSKY;
break;
case 8:
case 19:
att = STREDNI;
break;
default:
att = MUZSKY;
break;
}
#endif
if ((number == 1) && (att == MUZSKY)) {
if ((number == 1) && (att == MALE)) {
PUSH_NUMBER_PROMPT(CZ_PROMPT_JEDEN);
number = -1;
}
if ((number == 1) && (att == STREDNI)) {
if ((number == 1) && (att == NEUTRAL)) {
PUSH_NUMBER_PROMPT(CZ_PROMPT_JEDNO);
number = -1;
}
if ((number == 2) && ((att == ZENSKY) || (att == STREDNI))) {
if ((number == 2) && ((att == FEMALE) || (att == NEUTRAL))) {
PUSH_NUMBER_PROMPT(CZ_PROMPT_DVE);
number = -1;
}
if (number >= 1000) {
if (number >= 2000)
if (number >= 2000)
PLAY_NUMBER(number / 1000, 0, 0);
if (number >= 2000 && number < 5000)
PUSH_NUMBER_PROMPT(CZ_PROMPT_TISICE);
@@ -202,13 +185,13 @@ I18N_PLAY_FUNCTION(cz, playNumber, getvalue_t number, uint8_t unit, uint8_t att)
if (number == 0)
number = -1;
}
if (number >= 0) {
PUSH_NUMBER_PROMPT(CZ_PROMPT_NULA+number);
}
if (unit) {
CZ_PUSH_UNIT_PROMPT(tmp, unit);
CZ_PUSH_UNIT_PROMPT(unit, tmp);
}
}
@@ -222,17 +205,17 @@ I18N_PLAY_FUNCTION(cz, playDuration, int seconds PLAY_DURATION_ATT)
uint8_t tmp = seconds / 3600;
seconds %= 3600;
if (tmp > 0 || IS_PLAY_TIME()) {
PLAY_NUMBER(tmp, UNIT_HOURS, ZENSKY);
PLAY_NUMBER(tmp, UNIT_HOURS, FEMALE);
}
tmp = seconds / 60;
seconds %= 60;
if (tmp > 0) {
PLAY_NUMBER(tmp, UNIT_MINUTES, ZENSKY);
PLAY_NUMBER(tmp, UNIT_MINUTES, FEMALE);
}
if (seconds > 0) {
PLAY_NUMBER(seconds, UNIT_SECONDS, ZENSKY);
PLAY_NUMBER(seconds, UNIT_SECONDS, FEMALE);
}
}