Speech Recognition as a service.(Android)

2019-09-06 14:14发布

问题:

I am developing android application. I my application I need speech recognition.But I need speech recognition as service. I already create simple speech recognition in which when I click on button it start recognizer intent.It works fine and gives me output. But what I need when user click on button speech recognition start as service (in background).When user start specking it start recognizer and give me output.

I read few question regarding this but not getting proper solution to this kind of functionality. Is there any way to implement this. Need help... Thank you

回答1:

There is some code that does exactly what you need here:

https://github.com/gast-lib/gast-lib/blob/master/library/src/root/gast/speech/activation/SpeechActivationService.java

See it running by downloading this app.

The code is a Service that runs in the background, listening for the users speech. When the user speaks a certain word, it fires an Intent. The Service also puts up a handy Notification while it is listening. There is some other code that starts and stops it here.