summaryrefslogtreecommitdiffstats
path: root/pico
diff options
context:
space:
mode:
authorCharles Chen <clchen@google.com>2010-03-18 20:24:49 -0700
committerCharles Chen <clchen@google.com>2010-03-18 20:24:49 -0700
commitc0991bad280488a4b45b1819f8ac64a30820103d (patch)
treecb385821c282f7042936d7bcd80ece46e3daab0a /pico
parent68d3a7e3f9816e1b163081a51230232057495f16 (diff)
downloadexternal_svox-c0991bad280488a4b45b1819f8ac64a30820103d.zip
external_svox-c0991bad280488a4b45b1819f8ac64a30820103d.tar.gz
external_svox-c0991bad280488a4b45b1819f8ac64a30820103d.tar.bz2
Adding an EngineSettings screen to Pico that enables languages
to be installed individually. Change-Id: I29f98ff65a3c8c90747f635d0ad3887ab27a65d7
Diffstat (limited to 'pico')
-rwxr-xr-xpico/AndroidManifest.xml7
-rwxr-xr-xpico/res/values/strings.xml2
-rwxr-xr-xpico/res/xml/voices_list.xml39
-rwxr-xr-xpico/src/com/svox/pico/EngineSettings.java87
4 files changed, 135 insertions, 0 deletions
diff --git a/pico/AndroidManifest.xml b/pico/AndroidManifest.xml
index fcf6980..c8cb570 100755
--- a/pico/AndroidManifest.xml
+++ b/pico/AndroidManifest.xml
@@ -55,6 +55,13 @@
</intent-filter>
</activity>
+ <activity android:name=".EngineSettings" android:label="@string/app_name">
+ <intent-filter>
+ <action android:name="android.speech.tts.engine.CONFIGURE_ENGINE" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ </activity>
+
<activity android:enabled="true" android:name=".Pico"
android:hasCode="false" android:label="@string/app_name"
android:theme="@android:style/Theme.Translucent.NoTitleBar">
diff --git a/pico/res/values/strings.xml b/pico/res/values/strings.xml
index f68995a..932403d 100755
--- a/pico/res/values/strings.xml
+++ b/pico/res/values/strings.xml
@@ -26,4 +26,6 @@
<string name="deu_deu_sample">Dies ist ein Beispiel für Sprachsynthese in Deutsch mit Pico.</string>
<string name="ita_ita_sample">Questo è un esempio di sintesi vocale in italiano con Pico.</string>
<string name="spa_esp_sample">Este es un ejemplo de síntesis de voz en español con Pico.</string>
+ <string name="installed">Installed</string>
+ <string name="not_installed">Not Installed</string>
</resources>
diff --git a/pico/res/xml/voices_list.xml b/pico/res/xml/voices_list.xml
new file mode 100755
index 0000000..3b7e640
--- /dev/null
+++ b/pico/res/xml/voices_list.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+ android:title="@string/app_name">
+
+ <Preference
+ android:key="eng-USA"
+ android:persistent="false" />
+ <Preference
+ android:key="eng-GBR"
+ android:persistent="false" />
+ <Preference
+ android:key="fra-FRA"
+ android:persistent="false" />
+ <Preference
+ android:key="ita-ITA"
+ android:persistent="false" />
+ <Preference
+ android:key="deu-DEU"
+ android:persistent="false" />
+ <Preference
+ android:key="spa-ESP"
+ android:persistent="false" />
+
+</PreferenceScreen>
diff --git a/pico/src/com/svox/pico/EngineSettings.java b/pico/src/com/svox/pico/EngineSettings.java
new file mode 100755
index 0000000..dee798a
--- /dev/null
+++ b/pico/src/com/svox/pico/EngineSettings.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.svox.pico;
+
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.preference.Preference;
+import android.preference.PreferenceActivity;
+import android.preference.Preference.OnPreferenceClickListener;
+import android.util.Log;
+
+import java.util.ArrayList;
+import java.util.Locale;
+
+/*
+ * Checks if the voice data for the SVOX Pico Engine is present on the
+ * sd card.
+ */
+public class EngineSettings extends PreferenceActivity {
+ private final static String MARKET_URI_START = "market://search?q=pname:com.svox.pico.voice.";
+ private static final int VOICE_DATA_CHECK_CODE = 42;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ Intent i = new Intent();
+ i.setClass(this, CheckVoiceData.class);
+ startActivityForResult(i, VOICE_DATA_CHECK_CODE);
+ }
+
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent data){
+ if (requestCode == VOICE_DATA_CHECK_CODE){
+ ArrayList<String> available = data.getStringArrayListExtra("TextToSpeech.Engine.EXTRA_AVAILABLE_VOICES");
+ ArrayList<String> unavailable = data.getStringArrayListExtra("TextToSpeech.Engine.EXTRA_UNAVAILABLE_VOICES");
+
+ addPreferencesFromResource(R.xml.voices_list);
+
+ for (int i = 0; i < available.size(); i++){
+ Log.e("debug", available.get(i));
+ String[] languageCountry = available.get(i).split("-");
+ Locale loc = new Locale(languageCountry[0], languageCountry[1]);
+ Preference pref = findPreference(available.get(i));
+ pref.setTitle(loc.getDisplayLanguage() + " (" + loc.getDisplayCountry() + ")");
+ pref.setSummary(R.string.installed);
+ pref.setEnabled(false);
+ }
+
+
+ for (int i = 0; i < unavailable.size(); i++){
+ final String unavailableLang = unavailable.get(i);
+ String[] languageCountry = unavailableLang.split("-");
+ Locale loc = new Locale(languageCountry[0], languageCountry[1]);
+ Preference pref = findPreference(unavailableLang);
+ pref.setTitle(loc.getDisplayLanguage() + " (" + loc.getDisplayCountry() + ")");
+ pref.setSummary(R.string.not_installed);
+ pref.setEnabled(true);
+ pref.setOnPreferenceClickListener(new OnPreferenceClickListener(){
+ public boolean onPreferenceClick(Preference preference) {
+ Uri marketUri = Uri.parse(MARKET_URI_START + unavailableLang.toLowerCase().replace("-", "."));
+ Intent marketIntent = new Intent(Intent.ACTION_VIEW, marketUri);
+ startActivity(marketIntent);
+ return false;
+ }
+ });
+ }
+ }
+ }
+
+
+}