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/tts | |
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/tts')
-rw-r--r-- | pico/tts/com_svox_picottsengine.cpp | 50 |
1 files changed, 47 insertions, 3 deletions
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. */ |