/documentation/TextToSpeech_Plugin_Engine_Examples/README.txt

http://eyes-free.googlecode.com/ · Plain Text · 106 lines · 79 code · 27 blank · 0 comment · 0 complexity · 785ae1d8a4190663eeccd3540d9fd67c MD5 · raw file

  1. Architecture summary:
  2. 1/ frameworks/base/core/java/android/speech/tts/TextToSpeech.java
  3. This is the public API for TTS. It uses a TTS Android service whose interface
  4. is described in: frameworks/base/core/java/android/speech/tts/ITts.aidl
  5. All TTS calls an app makes through the TextToSpeech class are routed to the
  6. service (see the mITts member variable)
  7. 2/ frameworks/base/packages/TtsService/src/android/tts/TtsService.java
  8. This is the implementation of the TTS service. It handles the speech queue,
  9. and is responsible for instanciating the actuall speech synthesizer, an
  10. instance of the SynthProxy class, implemented in:
  11. frameworks/base/packages/TtsService/src/android/tts/SynthProxy.java
  12. 3/ frameworks/base/packages/TtsService/src/android/tts/SynthProxy.java
  13. This class, when instanciated, is given the full path of the speech synth
  14. native library to load. It is the bridge between Java and native code.
  15. 4/ frameworks/base/packages/TtsService/jni/android_tts_SynthProxy.cpp
  16. JNI for the SynthProxy class. It loads the synth native library whose
  17. interface is defined in frameworks/base/include/tts/TtsEngine.h.
  18. 5/ external/svox/pico/tts/com_svox_picottsengine.cpp
  19. An implementation of TtsEngine.h which is built into a shared library,
  20. loaded by android_tts_SynthProxy.cpp
  21. *******************************************************************************
  22. Here are the steps needed to create a TTS plugin that will work with the
  23. Android framework:
  24. I. Build the .so file
  25. The main piece of work that you need to do is write an equivalent of
  26. "com_svox_picottsengine.cpp", ie "com_mytts_ttsengine.cpp". This file
  27. must implement "TtsEngine.h" as seen here:
  28. http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob_plain;f=include/tts/TtsEngine.h;hb=master
  29. Use the Android NDK to build your .so file.
  30. See http://developer.android.com/sdk/ndk/index.html
  31. *******************************************************************************
  32. II. Package it inside an Android apk file.
  33. The Java APK wrapper MUST implement the following Activities:
  34. <NameOfEngine> - Declares which languages are potentially supported, name of
  35. the engine, etc. This is a dummy Activity that is used to get some basic info
  36. about the engine.
  37. DownloadVoiceData - Downloads data; this is the Activity that will be called
  38. if the engine is selected under TTS Settings and it needs voice data.
  39. CheckVoiceData - Determines which voices are actually present on the system.
  40. This will be used to determine which Languages the user can choose from in
  41. TTS Settings.
  42. GetSampleText - Sample text to be spoken to the user when they click
  43. "Listen to an example" in TTS Settings.
  44. ------------------------
  45. The Java APK wrapper can implement this Activity if it has Settings
  46. for the user to configure:
  47. EngineSettings - Engine specific configuration. This is the Activity
  48. that will be called if the user clicks on the engine specific settings
  49. under "Engines" in TTS Settings. What the user sets here will be passed
  50. to the .so as one String; it will be retrieved by the TTS Service by
  51. querying it from the engine's providers.SettingsProvider and then passed
  52. back to the .so in the native layer. If this is not implemented by your engine,
  53. the area under "Engines" will only have the enable/disable checkbox for
  54. your engine; there will not be a settings entry for your engine.
  55. ------------------------
  56. The Java APK wrapper can also implement this Content Provider:
  57. providers.SettingsProvider - Provides the String of config data that is to
  58. be passed to the engine's .so file. Normally this would be some data that
  59. you get from what the user has set in your EngineSettings Activity. The
  60. framework does not attempt to parse this data or do anything with it.
  61. It is up to the plugin vendor's Java wrapper to come up with this String,
  62. and it is up to the plugin vendor's engine .so to consume it. If you don't
  63. have this Content Provider, the native layer will just get an empty
  64. string passed to it.
  65. ------------------------
  66. For apps that use TTS, we expect that developers will probably want to use
  67. the dummy NameOfEngine Activity to narrow down which engines have support
  68. for the languages they are interested in, followed by invoking CheckVoiceData
  69. for the specific languages they are interested in.
  70. For examples, see:
  71. http://code.google.com/p/eyes-free/source/browse/#svn/trunk/documentation/TextToSpeech_Plugin_Engine_Examples
  72. Also, for a 3rd party example, see Flite for Android:
  73. http://github.com/happyalu/Flite-TTS-Engine-for-Android
  74. *******************************************************************************
  75. III. Stress test your TTS
  76. Make sure your TTS can handle starting and stopping speech rapidly. The easiest
  77. way to stress test your TTS is to use it with Android's built in TalkBack
  78. screen reader application and scroll around the various menus in Android. To
  79. enable TalkBack: Settings > Accessibility > TalkBack.