2011-12-19 17 views
6

Mam opracowane własne aplikacje TTS w systemie Android. Czy jest jakiś sposób wdrożenia mojego silnika TTS w systemie operacyjnym zamiast uruchamiania aplikacji TTS, aby inne aplikacje mogły wywoływać mój TTS? Coś takiego jak SAPI w MS Window. SVOX może spakować silnik jako apk i po zainstalowaniu dodaje nowe silniki do Andorid OS, nie wiem jak to zrobić.dodaj mój silnik TTS do systemu Android TTS Serivce jak SAPI

Odpowiedz

4

Aby twój silnik przetwarzania tekstu na mowę mógł pojawić się na liście dostępnych usług, musisz dodać odpowiednie działania i wpisy do manifestu.

Dla API 14 i powyżej, trzeba rozszerzyć TextToSpeechService i trzeba dodać następujące swoim manifeście:

<service 
     android:name=".MyTextToSpeechService" 
     android:label="@string/app_name" > 
     <intent-filter> 
      <action android:name="android.intent.action.TTS_SERVICE" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
     </intent-filter> 
     <meta-data 
      android:name="android.speech.tts" 
      android:resource="@xml/tts_engine" /> 
    </service> 

Ten referencje res/xml/tts_engine.xml, który powinien wyglądać tak:

<?xml version="1.0" encoding="utf-8"?> 
<tts-engine xmlns:android="http://schemas.android.com/apk/res/android" 
    android:settingsActivity="com.example.MyTtsSettingsActivity" /> 

Będziesz także potrzebować różnych działań pomocniczych. Oto co będziesz dodawanie do manifestu:

<activity 
     android:name=".DownloadVoiceData" 
     android:theme="@android:style/Theme.Dialog" > 
     <intent-filter> 
      <action android:name="android.speech.tts.engine.INSTALL_TTS_DATA" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
     </intent-filter> 
    </activity> 
    <activity 
     android:name=".CheckVoiceData" 
     android:theme="@android:style/Theme.Translucent.NoTitleBar" > 
     <intent-filter> 
      <action android:name="android.speech.tts.engine.CHECK_TTS_DATA" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
     </intent-filter> 
    </activity> 
    <activity 
     android:name=".GetSampleText" 
     android:theme="@android:style/Theme.Translucent.NoTitleBar" > 
     <intent-filter> 
      <action android:name="android.speech.tts.engine.GET_SAMPLE_TEXT" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
     </intent-filter> 
    </activity> 
    <activity 
     android:name=".TtsSettingsActivity" 
     android:label="@string/tts_settings_label" > 
     <intent-filter> 
      <action android:name="android.speech.tts.engine.CONFIGURE_ENGINE" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
     </intent-filter> 
    </activity> 

    <!-- Legacy code for pre-ICS compatibility. --> 
    <activity 
     android:name=".MyTtsEngine" 
     android:label="@string/app_name" 
     android:theme="@android:style/Theme.Translucent.NoTitleBar" > 
     <intent-filter> 
      <action android:name="android.intent.action.START_TTS_ENGINE" /> 
     </intent-filter> 
    </activity> 

    <provider 
     android:name="com.googlecode.eyesfree.espeak.providers.SettingsProvider" 
     android:authorities="com.googlecode.eyesfree.espeak.providers.SettingsProvider" /> 

Jeśli planujesz na wspieraniu wersje pre-ICS Androida, musisz również wspólną bibliotekę, która jest zgodna z określonym API.

Nie będę wdawać się w szczegóły realizacji każdego działania tutaj, lub do API pre-ICS, ale można znaleźć przykłady w kodzie źródłowym dla Androida portu silnika eSpeak TTS: http://code.google.com/p/eyes-free/source/browse/trunk/tts/espeak-tts/

Powiązane problemy