/documentation/TextToSpeech_Plugin_Engine_Examples/PicoUnbundled/src/com/svox/pico/unbundled/GetSampleText.java

http://eyes-free.googlecode.com/ · Java · 62 lines · 37 code · 7 blank · 18 comment · 12 complexity · f1f4f711a16e24bfff696a4bd48bd73e MD5 · raw file

  1. /*
  2. * Copyright (C) 2009 The Android Open Source Project
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package com.svox.pico.unbundled;
  17. import android.app.Activity;
  18. import android.content.Intent;
  19. import android.os.Bundle;
  20. import android.speech.tts.TextToSpeech;
  21. /*
  22. * Returns the sample text string for the language requested
  23. */
  24. public class GetSampleText extends Activity {
  25. @Override
  26. protected void onCreate(Bundle savedInstanceState) {
  27. super.onCreate(savedInstanceState);
  28. int result = TextToSpeech.LANG_AVAILABLE;
  29. Intent returnData = new Intent();
  30. Intent i = getIntent();
  31. String language = i.getExtras().getString("language");
  32. String country = i.getExtras().getString("country");
  33. String variant = i.getExtras().getString("variant");
  34. if (language.equals("eng")) {
  35. if (country.equals("GBR")){
  36. returnData.putExtra("sampleText", getString(R.string.eng_gbr_sample));
  37. } else {
  38. returnData.putExtra("sampleText", getString(R.string.eng_usa_sample));
  39. }
  40. } else if (language.equals("fra")) {
  41. returnData.putExtra("sampleText", getString(R.string.fra_fra_sample));
  42. } else if (language.equals("ita")) {
  43. returnData.putExtra("sampleText", getString(R.string.ita_ita_sample));
  44. } else if (language.equals("deu")) {
  45. returnData.putExtra("sampleText", getString(R.string.deu_deu_sample));
  46. } else if (language.equals("spa")) {
  47. returnData.putExtra("sampleText", getString(R.string.spa_esp_sample));
  48. } else {
  49. result = TextToSpeech.LANG_NOT_SUPPORTED;
  50. returnData.putExtra("sampleText", "");
  51. }
  52. setResult(result, null); //returnData);
  53. finish();
  54. }
  55. }