Loading core/java/android/speech/tts/ITts.aidl +4 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,10 @@ interface ITts { void addSpeechFile(in String text, in String filename); String[] getLanguage(); int isLanguageAvailable(in String language, in String country, in String variant); void setLanguage(in String language, in String country, in String variant); boolean synthesizeToFile(in String text, in String[] params, in String outputDirectory); Loading core/java/android/speech/tts/TextToSpeech.java +42 −4 Original line number Diff line number Diff line Loading @@ -657,18 +657,56 @@ public class TextToSpeech { /** * Checks if the specified language as represented by the locale is available. * Returns a Locale instance describing the language currently being used by the TTS engine. * @return language, country (if any) and variant (if any) used by the engine stored in a Locale * instance, or null is the TTS engine has failed. */ public Locale getLanguage() { synchronized (mStartLock) { if (!mStarted) { return null; } try { String[] locStrings = mITts.getLanguage(); if (locStrings.length == 3) { return new Locale(locStrings[0], locStrings[1], locStrings[2]); } else { return null; } } catch (RemoteException e) { // TTS died; restart it. mStarted = false; initTts(); } return null; } } /** * Checks if the specified language as represented by the Locale is available. * * @param loc * The locale describing the language to be used. * The Locale describing the language to be used. * * @return one of TTS_LANG_NOT_SUPPORTED, TTS_LANG_MISSING_DATA, TTS_LANG_AVAILABLE, * TTS_LANG_COUNTRY_AVAILABLE, TTS_LANG_COUNTRY_VAR_AVAILABLE. */ public int isLanguageAvailable(Locale loc) { //TODO: Implement isLanguageAvailable synchronized (mStartLock) { if (!mStarted) { return TTS_LANG_NOT_SUPPORTED; } try { return mITts.isLanguageAvailable(loc.getISO3Language(), loc.getISO3Country(), loc.getVariant()); } catch (RemoteException e) { // TTS died; restart it. mStarted = false; initTts(); } return TTS_LANG_NOT_SUPPORTED; } } /** Loading packages/TtsService/src/android/tts/TtsService.java +36 −2 Original line number Diff line number Diff line Loading @@ -148,8 +148,7 @@ public class TtsService extends Service implements OnCompletionListener { private void setDefaultSettings() { // TODO handle default language setLanguage("eng", "USA", ""); setLanguage(this.getDefaultLanguage(), getDefaultLanguage(), getDefaultLocVariant()); // speech rate setSpeechRate(getDefaultRate()); Loading Loading @@ -218,6 +217,17 @@ public class TtsService extends Service implements OnCompletionListener { } private int isLanguageAvailable(String lang, String country, String variant) { Log.v("TTS", "TtsService.isLanguageAvailable(" + lang + ", " + country + ", " +variant+")"); return nativeSynth.isLanguageAvailable(lang, country, variant); } private String[] getLanguage() { return nativeSynth.getLanguage(); } private void setLanguage(String lang, String country, String variant) { Log.v("TTS", "TtsService.setLanguage(" + lang + ", " + country + ", " + variant + ")"); if (isDefaultEnforced()) { Loading Loading @@ -892,6 +902,30 @@ public class TtsService extends Service implements OnCompletionListener { mSelf.setPitch(pitch); } /** * Returns the level of support for the specified language. * * @param lang the three letter ISO language code. * @param country the three letter ISO country code. * @param variant the variant code associated with the country and language pair. * @return one of TTS_LANG_NOT_SUPPORTED, TTS_LANG_MISSING_DATA, TTS_LANG_AVAILABLE, * TTS_LANG_COUNTRY_AVAILABLE, TTS_LANG_COUNTRY_VAR_AVAILABLE as defined in * android.speech.tts.TextToSpeech. */ public int isLanguageAvailable(String lang, String country, String variant) { return mSelf.isLanguageAvailable(lang, country, variant); } /** * Returns the currently set language / country / variant strings representing the * language used by the TTS engine. * @return null is no language is set, or an array of 3 string containing respectively * the language, country and variant. */ public String[] getLanguage() { return mSelf.getLanguage(); } /** * Sets the speech rate for the TTS, which affects the synthesized voice. * Loading Loading
core/java/android/speech/tts/ITts.aidl +4 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,10 @@ interface ITts { void addSpeechFile(in String text, in String filename); String[] getLanguage(); int isLanguageAvailable(in String language, in String country, in String variant); void setLanguage(in String language, in String country, in String variant); boolean synthesizeToFile(in String text, in String[] params, in String outputDirectory); Loading
core/java/android/speech/tts/TextToSpeech.java +42 −4 Original line number Diff line number Diff line Loading @@ -657,18 +657,56 @@ public class TextToSpeech { /** * Checks if the specified language as represented by the locale is available. * Returns a Locale instance describing the language currently being used by the TTS engine. * @return language, country (if any) and variant (if any) used by the engine stored in a Locale * instance, or null is the TTS engine has failed. */ public Locale getLanguage() { synchronized (mStartLock) { if (!mStarted) { return null; } try { String[] locStrings = mITts.getLanguage(); if (locStrings.length == 3) { return new Locale(locStrings[0], locStrings[1], locStrings[2]); } else { return null; } } catch (RemoteException e) { // TTS died; restart it. mStarted = false; initTts(); } return null; } } /** * Checks if the specified language as represented by the Locale is available. * * @param loc * The locale describing the language to be used. * The Locale describing the language to be used. * * @return one of TTS_LANG_NOT_SUPPORTED, TTS_LANG_MISSING_DATA, TTS_LANG_AVAILABLE, * TTS_LANG_COUNTRY_AVAILABLE, TTS_LANG_COUNTRY_VAR_AVAILABLE. */ public int isLanguageAvailable(Locale loc) { //TODO: Implement isLanguageAvailable synchronized (mStartLock) { if (!mStarted) { return TTS_LANG_NOT_SUPPORTED; } try { return mITts.isLanguageAvailable(loc.getISO3Language(), loc.getISO3Country(), loc.getVariant()); } catch (RemoteException e) { // TTS died; restart it. mStarted = false; initTts(); } return TTS_LANG_NOT_SUPPORTED; } } /** Loading
packages/TtsService/src/android/tts/TtsService.java +36 −2 Original line number Diff line number Diff line Loading @@ -148,8 +148,7 @@ public class TtsService extends Service implements OnCompletionListener { private void setDefaultSettings() { // TODO handle default language setLanguage("eng", "USA", ""); setLanguage(this.getDefaultLanguage(), getDefaultLanguage(), getDefaultLocVariant()); // speech rate setSpeechRate(getDefaultRate()); Loading Loading @@ -218,6 +217,17 @@ public class TtsService extends Service implements OnCompletionListener { } private int isLanguageAvailable(String lang, String country, String variant) { Log.v("TTS", "TtsService.isLanguageAvailable(" + lang + ", " + country + ", " +variant+")"); return nativeSynth.isLanguageAvailable(lang, country, variant); } private String[] getLanguage() { return nativeSynth.getLanguage(); } private void setLanguage(String lang, String country, String variant) { Log.v("TTS", "TtsService.setLanguage(" + lang + ", " + country + ", " + variant + ")"); if (isDefaultEnforced()) { Loading Loading @@ -892,6 +902,30 @@ public class TtsService extends Service implements OnCompletionListener { mSelf.setPitch(pitch); } /** * Returns the level of support for the specified language. * * @param lang the three letter ISO language code. * @param country the three letter ISO country code. * @param variant the variant code associated with the country and language pair. * @return one of TTS_LANG_NOT_SUPPORTED, TTS_LANG_MISSING_DATA, TTS_LANG_AVAILABLE, * TTS_LANG_COUNTRY_AVAILABLE, TTS_LANG_COUNTRY_VAR_AVAILABLE as defined in * android.speech.tts.TextToSpeech. */ public int isLanguageAvailable(String lang, String country, String variant) { return mSelf.isLanguageAvailable(lang, country, variant); } /** * Returns the currently set language / country / variant strings representing the * language used by the TTS engine. * @return null is no language is set, or an array of 3 string containing respectively * the language, country and variant. */ public String[] getLanguage() { return mSelf.getLanguage(); } /** * Sets the speech rate for the TTS, which affects the synthesized voice. * Loading