diff options
author | Jean-Michel Trivi <jmtrivi@google.com> | 2009-08-04 16:22:51 -0700 |
---|---|---|
committer | Jean-Michel Trivi <jmtrivi@google.com> | 2009-08-05 08:57:57 -0700 |
commit | a8d076f716bca609b7e740cd888177fbc589a521 (patch) | |
tree | ae314548cd0613131a3fb0bdce29366b7f20263e /pico | |
parent | 40a6eb8ef562424f4dc2324b50e1b00d58ec3c30 (diff) | |
download | external_svox-a8d076f716bca609b7e740cd888177fbc589a521.zip external_svox-a8d076f716bca609b7e740cd888177fbc589a521.tar.gz external_svox-a8d076f716bca609b7e740cd888177fbc589a521.tar.bz2 |
Fix bug 2022411.
Added support for TTS language files to be loaded from the system partition if
they are not available on the regular path (sdcard). This involves changing
the check for the availability of a language (first check in the system path,
then check the sdcard), and the language switch code (try to load from the
system path if cannot load from sdcard).
Modified the CheckVoiceData activity (which checks for the installation of
all language files) to check on both the sdcard and the system path.
Added makefiles for copying language files to the system image,
PicoLangDefaultInSystem.mk will be used in another CL to copy a default language
to the system.
Diffstat (limited to 'pico')
-rw-r--r-- | pico/lang/PicoLangDeDeInSystem.mk | 14 | ||||
-rw-r--r-- | pico/lang/PicoLangDefaultInSystem.mk | 14 | ||||
-rw-r--r-- | pico/lang/PicoLangEnGBInSystem.mk | 14 | ||||
-rw-r--r-- | pico/lang/PicoLangEnUsInSystem.mk | 14 | ||||
-rw-r--r-- | pico/lang/PicoLangEsEsInSystem.mk | 14 | ||||
-rw-r--r-- | pico/lang/PicoLangFrFrInSystem.mk | 14 | ||||
-rw-r--r-- | pico/lang/PicoLangItItInSystem.mk | 14 | ||||
-rwxr-xr-x | pico/src/com/svox/pico/CheckVoiceData.java | 18 | ||||
-rw-r--r-- | pico/tts/com_svox_picottsengine.cpp | 50 |
9 files changed, 154 insertions, 12 deletions
diff --git a/pico/lang/PicoLangDeDeInSystem.mk b/pico/lang/PicoLangDeDeInSystem.mk new file mode 100644 index 0000000..174bc1b --- /dev/null +++ b/pico/lang/PicoLangDeDeInSystem.mk @@ -0,0 +1,14 @@ +# +# Installation of de-DE for the Pico TTS engine in the system image +# +# Include this file in a product makefile to include the language files for de-DE +# +# Note the destination path matches that used in external/svox/pico/tts/com_svox_picottsengine.cpp +# + +LOCAL_PATH:= external/svox/pico/lang + +PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/de-DE_gl0_sg.bin:system/tts/lang_pico/de-DE_gl0_sg.bin \ + $(LOCAL_PATH)/de-DE_ta.bin:system/tts/lang_pico/de-DE_ta.bin + diff --git a/pico/lang/PicoLangDefaultInSystem.mk b/pico/lang/PicoLangDefaultInSystem.mk new file mode 100644 index 0000000..5e31e82 --- /dev/null +++ b/pico/lang/PicoLangDefaultInSystem.mk @@ -0,0 +1,14 @@ +# +# Installation of a default language for the Pico TTS engine +# +# Include this file in a product makefile to include the language files for english US +# +# Note the destination path matches that used in external/svox/pico/tts/com_svox_picottsengine.cpp +# + +LOCAL_PATH:= external/svox/pico/lang + +PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/en-US_lh0_sg.bin:system/tts/lang_pico/en-US_lh0_sg.bin \ + $(LOCAL_PATH)/en-US_ta.bin:system/tts/lang_pico/en-US_ta.bin + diff --git a/pico/lang/PicoLangEnGBInSystem.mk b/pico/lang/PicoLangEnGBInSystem.mk new file mode 100644 index 0000000..a07f50e --- /dev/null +++ b/pico/lang/PicoLangEnGBInSystem.mk @@ -0,0 +1,14 @@ +# +# Installation of en-GB for the Pico TTS engine in the system image +# +# Include this file in a product makefile to include the language files for en-GB +# +# Note the destination path matches that used in external/svox/pico/tts/com_svox_picottsengine.cpp +# + +LOCAL_PATH:= external/svox/pico/lang + +PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/en-GB_kh0_sg.bin:system/tts/lang_pico/en-GB_kh0_sg.bin \ + $(LOCAL_PATH)/en-GB_ta.bin:system/tts/lang_pico/en-GB_ta.bin + diff --git a/pico/lang/PicoLangEnUsInSystem.mk b/pico/lang/PicoLangEnUsInSystem.mk new file mode 100644 index 0000000..5ac7646 --- /dev/null +++ b/pico/lang/PicoLangEnUsInSystem.mk @@ -0,0 +1,14 @@ +# +# Installation of en-US for the Pico TTS engine in the system image +# +# Include this file in a product makefile to include the language files for english US +# +# Note the destination path matches that used in external/svox/pico/tts/com_svox_picottsengine.cpp +# + +LOCAL_PATH:= external/svox/pico/lang + +PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/en-US_lh0_sg.bin:system/tts/lang_pico/en-US_lh0_sg.bin \ + $(LOCAL_PATH)/en-US_ta.bin:system/tts/lang_pico/en-US_ta.bin + diff --git a/pico/lang/PicoLangEsEsInSystem.mk b/pico/lang/PicoLangEsEsInSystem.mk new file mode 100644 index 0000000..49165f2 --- /dev/null +++ b/pico/lang/PicoLangEsEsInSystem.mk @@ -0,0 +1,14 @@ +# +# Installation of es-ES for the Pico TTS engine in the system image +# +# Include this file in a product makefile to include the language files for es-ES +# +# Note the destination path matches that used in external/svox/pico/tts/com_svox_picottsengine.cpp +# + +LOCAL_PATH:= external/svox/pico/lang + +PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/es-ES_zl0_sg.bin:system/tts/lang_pico/es-ES_zl0_sg.bin \ + $(LOCAL_PATH)/es-ES_ta.bin:system/tts/lang_pico/es-ES_ta.bin + diff --git a/pico/lang/PicoLangFrFrInSystem.mk b/pico/lang/PicoLangFrFrInSystem.mk new file mode 100644 index 0000000..619a0cf --- /dev/null +++ b/pico/lang/PicoLangFrFrInSystem.mk @@ -0,0 +1,14 @@ +# +# Installation of fr-FR for the Pico TTS engine in the system image +# +# Include this file in a product makefile to include the language files for fr-FR +# +# Note the destination path matches that used in external/svox/pico/tts/com_svox_picottsengine.cpp +# + +LOCAL_PATH:= external/svox/pico/lang + +PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/fr-FR_nk0_sg.bin:system/tts/lang_pico/fr-FR_nk0_sg.bin \ + $(LOCAL_PATH)/fr-FR_ta.bin:system/tts/lang_pico/fr-FR_ta.bin + diff --git a/pico/lang/PicoLangItItInSystem.mk b/pico/lang/PicoLangItItInSystem.mk new file mode 100644 index 0000000..c10cf36 --- /dev/null +++ b/pico/lang/PicoLangItItInSystem.mk @@ -0,0 +1,14 @@ +# +# Installation of it-IT for the Pico TTS engine in the system image +# +# Include this file in a product makefile to include the language files for it-IT +# +# Note the destination path matches that used in external/svox/pico/tts/com_svox_picottsengine.cpp +# + +LOCAL_PATH:= external/svox/pico/lang + +PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/it-IT_cm0_sg.bin:system/tts/lang_pico/it-IT_cm0_sg.bin \ + $(LOCAL_PATH)/it-IT_ta.bin:system/tts/lang_pico/it-IT_ta.bin + diff --git a/pico/src/com/svox/pico/CheckVoiceData.java b/pico/src/com/svox/pico/CheckVoiceData.java index 6e6e59f..036be3b 100755 --- a/pico/src/com/svox/pico/CheckVoiceData.java +++ b/pico/src/com/svox/pico/CheckVoiceData.java @@ -28,7 +28,11 @@ import android.speech.tts.TextToSpeech; * sd card. */ public class CheckVoiceData extends Activity { - private final static String dataDir = "/sdcard/svox/"; + + // The following constants are the same path constants as the ones defined + // in external/svox/pico/tts/com_svox_picottsengine.cpp + private final static String PICO_LINGWARE_PATH = "/sdcard/svox/"; + private final static String PICO_SYSTEM_LINGWARE_PATH = "/system/tts/lang_pico/"; private final static String[] dataFiles = { "de-DE_gl0_sg.bin", "de-DE_ta.bin", "en-GB_kh0_sg.bin", "en-GB_ta.bin", @@ -47,22 +51,18 @@ public class CheckVoiceData extends Activity { int result = TextToSpeech.Engine.CHECK_VOICE_DATA_PASS; - // Make sure the SD card is accessible - if (!new File("/sdcard/").canRead()) { - result = TextToSpeech.Engine.CHECK_VOICE_DATA_MISSING_VOLUME; - } - // Check for files for (int i = 0; i < dataFiles.length; i++) { - File tempFile = new File(dataDir + dataFiles[i]); - if (!tempFile.exists()) { + File tempFile = new File(PICO_LINGWARE_PATH + dataFiles[i]); + File tempFileSys = new File(PICO_SYSTEM_LINGWARE_PATH + dataFiles[i]); + if ((!tempFile.exists()) && (!tempFileSys.exists())) { result = TextToSpeech.Engine.CHECK_VOICE_DATA_MISSING_DATA; } } // Put the root directory for the sd card data + the data filenames Intent returnData = new Intent(); - returnData.putExtra(TextToSpeech.Engine.EXTRA_VOICE_DATA_ROOT_DIRECTORY, dataDir); + returnData.putExtra(TextToSpeech.Engine.EXTRA_VOICE_DATA_ROOT_DIRECTORY, PICO_LINGWARE_PATH); returnData.putExtra(TextToSpeech.Engine.EXTRA_VOICE_DATA_FILES, dataFiles); returnData.putExtra(TextToSpeech.Engine.EXTRA_VOICE_DATA_FILES_INFO, dataFilesInfo); diff --git a/pico/tts/com_svox_picottsengine.cpp b/pico/tts/com_svox_picottsengine.cpp index e5c6994..f7df2a4 100644 --- a/pico/tts/com_svox_picottsengine.cpp +++ b/pico/tts/com_svox_picottsengine.cpp @@ -64,6 +64,7 @@ using namespace android; /* string constants */ #define MAX_OUTBUF_SIZE 128 +const char * PICO_SYSTEM_LINGWARE_PATH = "/system/tts/lang_pico/"; const char * PICO_LINGWARE_PATH = "/sdcard/svox/"; const char * PICO_VOICE_NAME = "PicoVoice"; const char * PICO_SPEED_OPEN_TAG = "<speed level='%d'>"; @@ -238,6 +239,27 @@ static bool hasResourcesForLanguage(int langIndex) { FILE * pFile; char* fileName = (char*)malloc(PICO_MAX_DATAPATH_NAME_SIZE + PICO_MAX_FILE_NAME_SIZE); + /* check resources on system (under PICO_SYSTEM_LINGWARE_PATH). */ + strcpy((char*)fileName, PICO_SYSTEM_LINGWARE_PATH); + strcat((char*)fileName, (const char*)picoInternalTaLingware[langIndex]); + pFile = fopen(fileName, "r"); + if (pFile != NULL) { + /* "ta" file found. */ + fclose (pFile); + /* now look for "sg" file. */ + strcpy((char*)fileName, PICO_SYSTEM_LINGWARE_PATH); + strcat((char*)fileName, (const char*)picoInternalSgLingware[langIndex]); + pFile = fopen(fileName, "r"); + if (pFile != NULL) { + /* "sg" file found, no need to continue checking, return success. */ + fclose(pFile); + free(fileName); + return true; + } + } + + /* resources not found on system, check resources on alternative location */ + /* (under PICO_LINGWARE_PATH). */ strcpy((char*)fileName, PICO_LINGWARE_PATH); strcat((char*)fileName, (const char*)picoInternalTaLingware[langIndex]); pFile = fopen(fileName, "r"); @@ -315,12 +337,34 @@ static tts_result doLanguageSwitchFromLangIndex( int langIndex ) return TTS_FAILURE; } + /* Find where to load the resource files from: system or alternative location */ + /* based on availability of the Ta file. Try the alternative location first, this is where */ + /* more recent language file updates would be installed (under PICO_LINGWARE_PATH). */ + bool bUseSystemPath = true; + FILE * pFile; + char* tmpFileName = (char*)malloc(PICO_MAX_DATAPATH_NAME_SIZE + PICO_MAX_FILE_NAME_SIZE); + strcpy((char*)tmpFileName, PICO_LINGWARE_PATH); + strcat((char*)tmpFileName, (const char*)picoInternalTaLingware[langIndex]); + pFile = fopen(tmpFileName, "r"); + if (pFile != NULL) { + /* "ta" file found under PICO_LINGWARE_PATH, don't use the system path. */ + fclose (pFile); + bUseSystemPath = false; + } + free(tmpFileName); + /* Set the path and file names for resource files. */ - strcpy((char *) picoTaFileName, PICO_LINGWARE_PATH); + if (bUseSystemPath) { + strcpy((char *) picoTaFileName, PICO_SYSTEM_LINGWARE_PATH); + strcpy((char *) picoSgFileName, PICO_SYSTEM_LINGWARE_PATH); + strcpy((char *) picoUtppFileName, PICO_SYSTEM_LINGWARE_PATH); + } else { + strcpy((char *) picoTaFileName, PICO_LINGWARE_PATH); + strcpy((char *) picoSgFileName, PICO_LINGWARE_PATH); + strcpy((char *) picoUtppFileName, PICO_LINGWARE_PATH); + } strcat((char *) picoTaFileName, (const char *) picoInternalTaLingware[langIndex]); - strcpy((char *) picoSgFileName, PICO_LINGWARE_PATH); strcat((char *) picoSgFileName, (const char *) picoInternalSgLingware[langIndex]); - strcpy((char *) picoUtppFileName, PICO_LINGWARE_PATH); strcat((char *) picoUtppFileName, (const char *) picoInternalUtppLingware[langIndex]); /* Load the text analysis Lingware resource file. */ |