How to register a custom speech recognition service?

空扰寡人 提交于 2019-11-28 06:37:40

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.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!