How to register a custom speech recognition service?

前端 未结 2 1769
广开言路
广开言路 2020-12-08 17:40

I created a simple speech recognition service: for this purpose I created a subclass of android.speech.RecognitionService and I created an activity to start and

相关标签:
2条回答
  • 2020-12-08 18:18

    Yes, you need to use createSpeechRecognizer(Context context, ComponentName serviceComponent)

    0 讨论(0)
  • 2020-12-08 18:21

    If you want queryIntentActivities(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0) to pick up your activity (VoiceServiceStarterActivity) then you have to declare in your app's Manifest that this activity handles RecognizerIntent.ACTION_RECOGNIZE_SPEECH, like this

    <activity android:name="VoiceServiceStarterActivity">
      <intent-filter>
        <action android:name="android.speech.action.RECOGNIZE_SPEECH" />
        <category android:name="android.intent.category.DEFAULT" />
      </intent-filter>
      ...
    </activity>
    

    For more concrete code have a look at the project Kõnele (source code) which is essentially an open source implementation of the interfaces via which speech recognition is provided on Android, i.e. it covers:

    • ACTION_RECOGNIZE_SPEECH
    • ACTION_WEB_SEARCH
    • RecognitionService

    and uses open source speech recognition servers.

    0 讨论(0)
提交回复
热议问题