From a0a94f5493727c87423eb699c79d24fb05a2b5fd Mon Sep 17 00:00:00 2001 From: zyren <585668@qq.com> Date: Tue, 10 Aug 2021 13:04:07 +0800 Subject: [PATCH 01/10] Added Chinese voice The complete Chinese voice has been submitted to the repository edgetx-sdcard --- radio/src/CMakeLists.txt | 2 +- radio/src/translations.h | 2 + radio/src/translations/tts_cn.cpp | 142 ++++++++++++++++++++++++++++++ 3 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 radio/src/translations/tts_cn.cpp diff --git a/radio/src/CMakeLists.txt b/radio/src/CMakeLists.txt index 9d712e8de..4b7a7457d 100644 --- a/radio/src/CMakeLists.txt +++ b/radio/src/CMakeLists.txt @@ -3,7 +3,7 @@ include(Bitmaps) set(PCB_TYPES X9LITE X9LITES X7 XLITE XLITES X9D X9D+ X9E X10 X12S SKY9X 9XRPRO AR9X NV14) set(RADIO_LANGUAGES CZ DE EN ES FR IT PT SK SE PL HU NL CN TW) -set(TTS_LANGUAGES CZ DE EN ES FR IT PT SK SE PL HU NL RU) +set(TTS_LANGUAGES CZ DE EN ES FR IT PT SK SE PL HU NL RU CN) set(PCB "X9D+" CACHE STRING "Radio type, one of: ${PCB_TYPES}") set_property(CACHE PCB PROPERTY STRINGS ${PCB_TYPES}) diff --git a/radio/src/translations.h b/radio/src/translations.h index 74f3d3399..787db651b 100644 --- a/radio/src/translations.h +++ b/radio/src/translations.h @@ -745,6 +745,7 @@ extern const LanguagePack ptLanguagePack; extern const LanguagePack ruLanguagePack; extern const LanguagePack seLanguagePack; extern const LanguagePack skLanguagePack; +extern const LanguagePack cnLanguagePack; extern const LanguagePack * const languagePacks[]; #if defined(LANGUAGE_PACKS_DEFINITION) @@ -763,6 +764,7 @@ const LanguagePack * const languagePacks[] = { &ruLanguagePack, &seLanguagePack, &skLanguagePack, + &cnLanguagePack, NULL }; #endif diff --git a/radio/src/translations/tts_cn.cpp b/radio/src/translations/tts_cn.cpp new file mode 100644 index 000000000..3b9515d4e --- /dev/null +++ b/radio/src/translations/tts_cn.cpp @@ -0,0 +1,142 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "opentx.h" + +enum EnglishPrompts { + CN_PROMPT_NUMBERS_BASE = 0, + CN_PROMPT_ZERO = CN_PROMPT_NUMBERS_BASE+0, //02-99 + CN_PROMPT_HUNDRED = CN_PROMPT_NUMBERS_BASE+100, //100,200 .. 900 + CN_PROMPT_THOUSAND = CN_PROMPT_NUMBERS_BASE+109, //1000 + CN_PROMPT_AND = CN_PROMPT_NUMBERS_BASE+110, + CN_PROMPT_MINUS = CN_PROMPT_NUMBERS_BASE+111, + CN_PROMPT_POINT = CN_PROMPT_NUMBERS_BASE+112, + CN_PROMPT_UNITS_BASE = 113, + CN_PROMPT_POINT_BASE = 167, //.0 - .9 +}; + + + #define CN_PUSH_UNIT_PROMPT(u, p) cn_pushUnitPrompt((u), (p), id) + +I18N_PLAY_FUNCTION(cn, pushUnitPrompt, uint8_t unitprompt, int16_t number) +{ + if (number == 1) + PUSH_UNIT_PROMPT(unitprompt, 0); + else + PUSH_UNIT_PROMPT(unitprompt, 1); +} + +I18N_PLAY_FUNCTION(cn, playNumber, getvalue_t number, uint8_t unit, uint8_t att) +{ + if (number < 0) { + PUSH_NUMBER_PROMPT(CN_PROMPT_MINUS); + number = -number; + } + + + int8_t mode = MODE(att); + if (mode > 0) { + if (mode == 2) { + number /= 10; + } + div_t qr = div((int)number, 10); + if (qr.rem) { + PLAY_NUMBER(qr.quot, 0, 0); + PUSH_NUMBER_PROMPT(CN_PROMPT_POINT_BASE + qr.rem); + number = -1; + } + else { + number = qr.quot; + } + } + + int16_t tmp = number; + + if (number >= 1000) { + PLAY_NUMBER(number / 1000, 0, 0); + PUSH_NUMBER_PROMPT(CN_PROMPT_THOUSAND); + number %= 1000; + if (number == 0) + number = -1; + } + if (number >= 100) { + PUSH_NUMBER_PROMPT(CN_PROMPT_HUNDRED + (number/100)-1); + number %= 100; + if (number == 0) + number = -1; + } + if (number >= 0) { + PUSH_NUMBER_PROMPT(CN_PROMPT_ZERO + number); + } + + if (unit) { + CN_PUSH_UNIT_PROMPT(unit, tmp); + } +} + +I18N_PLAY_FUNCTION(cn, playDuration, int seconds PLAY_DURATION_ATT) +{ + if (seconds == 0) { + PLAY_NUMBER(seconds, 0, 0); + return; + } + + if (seconds < 0) { + PUSH_NUMBER_PROMPT(CN_PROMPT_MINUS); + seconds = -seconds; + } + + uint8_t tmp = seconds / 3600; + seconds %= 3600; + if (tmp > 0 || IS_PLAY_TIME()) { + PLAY_NUMBER(tmp, UNIT_HOURS, 0); + } + + tmp = seconds / 60; + seconds %= 60; + if (tmp > 0) { + PLAY_NUMBER(tmp, UNIT_MINUTES, 0); + if (seconds > 0) + PUSH_NUMBER_PROMPT(CN_PROMPT_AND); + } + + if (seconds > 0) { + PLAY_NUMBER(seconds, UNIT_SECONDS, 0); + } +} + +LANGUAGE_PACK_DECLARE(cn, "Chinese"); + From d92c5693884d77a43c399676c7f9ea1ec583e686 Mon Sep 17 00:00:00 2001 From: zyren Date: Thu, 12 Aug 2021 13:42:38 +0800 Subject: [PATCH 02/10] Update translations.h --- radio/src/translations.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radio/src/translations.h b/radio/src/translations.h index 787db651b..f5f56bf86 100644 --- a/radio/src/translations.h +++ b/radio/src/translations.h @@ -1,5 +1,5 @@ /* - * Copyright (C) OpenTX + * Copyright (C) EdgeTX * * Based on code named * th9x - http://code.google.com/p/th9x From 07119ea1fad9c4b6ddc88a3d03e694cac49259ba Mon Sep 17 00:00:00 2001 From: zyren Date: Thu, 12 Aug 2021 13:43:28 +0800 Subject: [PATCH 03/10] Update tts_cn.cpp --- radio/src/translations/tts_cn.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radio/src/translations/tts_cn.cpp b/radio/src/translations/tts_cn.cpp index 3b9515d4e..fd45d1de6 100644 --- a/radio/src/translations/tts_cn.cpp +++ b/radio/src/translations/tts_cn.cpp @@ -17,7 +17,7 @@ * - Romolo Manfredini * - Thomas Husterer * - * opentx is based on code named + * EdgeTX is based on code named * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, * er9x by Erez Raviv: http://code.google.com/p/er9x/, * and the original (and ongoing) project by From ff1d3b0b2fc1762c0bf6a67d9c5ea4186657969a Mon Sep 17 00:00:00 2001 From: zyren Date: Thu, 12 Aug 2021 13:46:08 +0800 Subject: [PATCH 04/10] Update tts_cn.cpp --- radio/src/translations/tts_cn.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/radio/src/translations/tts_cn.cpp b/radio/src/translations/tts_cn.cpp index fd45d1de6..1017ba32d 100644 --- a/radio/src/translations/tts_cn.cpp +++ b/radio/src/translations/tts_cn.cpp @@ -16,6 +16,7 @@ * - Rob Thomson * - Romolo Manfredini * - Thomas Husterer + * - Ziyu Ren * * EdgeTX is based on code named * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, From fb6755b4b1ccbb66a1c097c0cb5bbe9d2d464f54 Mon Sep 17 00:00:00 2001 From: zyren Date: Thu, 12 Aug 2021 13:51:02 +0800 Subject: [PATCH 05/10] Update translations.h --- radio/src/translations.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/radio/src/translations.h b/radio/src/translations.h index f5f56bf86..d6778c500 100644 --- a/radio/src/translations.h +++ b/radio/src/translations.h @@ -1,7 +1,9 @@ + /* * Copyright (C) EdgeTX * * Based on code named + * opentx - https://github.com/opentx/opentx * th9x - http://code.google.com/p/th9x * er9x - http://code.google.com/p/er9x * gruvin9x - http://code.google.com/p/gruvin9x From 8adb56bfa2aa4cbed793534dec0aa032af88d666 Mon Sep 17 00:00:00 2001 From: zyren Date: Thu, 12 Aug 2021 13:52:27 +0800 Subject: [PATCH 06/10] Update tts_cn.cpp --- radio/src/translations/tts_cn.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/radio/src/translations/tts_cn.cpp b/radio/src/translations/tts_cn.cpp index 1017ba32d..78350fdb5 100644 --- a/radio/src/translations/tts_cn.cpp +++ b/radio/src/translations/tts_cn.cpp @@ -18,11 +18,13 @@ * - Thomas Husterer * - Ziyu Ren * - * EdgeTX is based on code named - * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, - * er9x by Erez Raviv: http://code.google.com/p/er9x/, - * and the original (and ongoing) project by - * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * EdgeTX is Based on code named + * opentx - https://github.com/opentx/opentx + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -32,7 +34,6 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * */ #include "opentx.h" From 246d7f7e00e8d18b0b087b6d4f97896a3905ef58 Mon Sep 17 00:00:00 2001 From: zyren Date: Thu, 12 Aug 2021 13:57:14 +0800 Subject: [PATCH 07/10] Update tts_cn.cpp --- radio/src/translations/tts_cn.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radio/src/translations/tts_cn.cpp b/radio/src/translations/tts_cn.cpp index 78350fdb5..368cd09a8 100644 --- a/radio/src/translations/tts_cn.cpp +++ b/radio/src/translations/tts_cn.cpp @@ -38,7 +38,7 @@ #include "opentx.h" -enum EnglishPrompts { +enum ChinesePrompts { CN_PROMPT_NUMBERS_BASE = 0, CN_PROMPT_ZERO = CN_PROMPT_NUMBERS_BASE+0, //02-99 CN_PROMPT_HUNDRED = CN_PROMPT_NUMBERS_BASE+100, //100,200 .. 900 From b3ecb1463b25eb6c95cc5af39d5919cd3bbac745 Mon Sep 17 00:00:00 2001 From: zyren Date: Thu, 12 Aug 2021 14:07:11 +0800 Subject: [PATCH 08/10] Update tts_cn.cpp --- radio/src/translations/tts_cn.cpp | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/radio/src/translations/tts_cn.cpp b/radio/src/translations/tts_cn.cpp index 368cd09a8..8231b2c5b 100644 --- a/radio/src/translations/tts_cn.cpp +++ b/radio/src/translations/tts_cn.cpp @@ -1,22 +1,6 @@ /* * Authors (alphabetical order) - * - Andre Bernet - * - Andreas Weitl - * - Bertrand Songis - * - Bryan J. Rentoul (Gruvin) - * - Cameron Weeks - * - Erez Raviv - * - Gabriel Birkus - * - Jean-Pierre Parisy - * - Karl Szmutny - * - Michael Blandford - * - Michal Hlavinka - * - Pat Mackenzie - * - Philip Moss - * - Rob Thomson - * - Romolo Manfredini - * - Thomas Husterer - * - Ziyu Ren + * - Ziyu Ren(radiomaster) * * EdgeTX is Based on code named * opentx - https://github.com/opentx/opentx From 6e080a5ec1b7feebddd948d45d9686780158ffa6 Mon Sep 17 00:00:00 2001 From: zyren Date: Thu, 12 Aug 2021 14:09:47 +0800 Subject: [PATCH 09/10] Update tts_cn.cpp --- radio/src/translations/tts_cn.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radio/src/translations/tts_cn.cpp b/radio/src/translations/tts_cn.cpp index 8231b2c5b..e0eb80851 100644 --- a/radio/src/translations/tts_cn.cpp +++ b/radio/src/translations/tts_cn.cpp @@ -1,6 +1,6 @@ /* * Authors (alphabetical order) - * - Ziyu Ren(radiomaster) + * - Ziyu Ren (Radiomaster) * * EdgeTX is Based on code named * opentx - https://github.com/opentx/opentx From 669866ec930e98c832b019d4eea6945b034ee9e4 Mon Sep 17 00:00:00 2001 From: zyren Date: Fri, 13 Aug 2021 00:14:41 +0800 Subject: [PATCH 10/10] Update tts_cn.cpp --- radio/src/translations/tts_cn.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radio/src/translations/tts_cn.cpp b/radio/src/translations/tts_cn.cpp index e0eb80851..94402e9e5 100644 --- a/radio/src/translations/tts_cn.cpp +++ b/radio/src/translations/tts_cn.cpp @@ -1,6 +1,6 @@ /* * Authors (alphabetical order) - * - Ziyu Ren (Radiomaster) + * - Ziyu Ren * * EdgeTX is Based on code named * opentx - https://github.com/opentx/opentx