Java – how do I implement google voice input in my application?

I'm trying to add a button to my application to start Google Voice typing (or default voice recognition) I tried following this tutorial This tutorial is incredibly confusing to me I imported it Jar and add the necessary permissions, services and activities to my list But I can't seem to figure out how to "put it together" I was thinking:

Should I call inputmethodservice from the button in my main activity? Or is my inputmethodservice essentially my main activity? > What does ime mean? I tried Google, but the definition it gave me didn't help me understand. > When I try to copy and paste the entire demoinputmethodservice code into my current activity, I receive an error indicating that I cannot extend inputmethodservice within this activity (one question to ask later)

How can I make this work?

Solution

If you want to follow the tutorial you mentioned, you need to implement an IME (input method editor) first. See http://developer.android.com/guide/topics/text/creating-input-method.html

This ime can have a normal keyboard appearance or contain only a microphone button

Users of your application must first click the text field to start ime (note that several imes may be installed on the device and must be explicitly enabled in settings) The user will then have to click the microphone button to trigger speech recognition

This tutorial provides a jar that lets you call Google recognizer directly If you use the speechrecognizer interface( http://developer.android.com/reference/android/speech/SpeechRecognizer.html )Call recognizer, then users can decide whether to use Google or other content, which will be better

Speechrecognizer is given a listener that supports the method onpartialresults, which allows you to monitor recognition assumptions when users speak It depends on how you display them Note, however, that the speechrecognizer specification does not promise that this method will be called This depends on the implementation of the recognizer service About Google's implementation: what it supports is changing, no public API, and even no release notes

You may be able to reuse my project K õ Nele( http://kaljurand.github.io/K6nele/about/ ), which contains two implementations of speechrecognizer and ime using them One implementation uses the Kaldi GStreamer server( https://github.com/alumae/kaldi-gstreamer-server )It can continuously recognize any long audio input You will need to set your own server port to the language you want to recognize (unless you want to use K õ Nele's default Estonian server)

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>