Speech recognition , unknown error issue in android - android

I am trying to do a browser control appication with voice in android. I am using RecognizerIntent.ACTION_RECOGNIZE_SPEECH intent to recognize voice. It usually works but sometimes when voice recognition pop up opens and comes with "unknown problem" and my WebView don't load my URL, stays with old URL.
Here is my code:
//Load web view to default search screen
webView.loadUrl(Constant.DEFAULT_VOICE_BG);
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.ACTION_RECOGNIZE_SPEECH, getClass()
.getPackage().getName());
intent.putExtra(RecognizerIntent.EXTRA_PROMPT,
GeneralConstants.TEXT_VOICE);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 5);
startActivityForResult(intent,
GeneralConstants.VOICE_RECOGNITION_REQUEST_CODE);
Thanks for any idea.
Best Regards.

Related

Persian speech to text in android

i want to improve my knowledge and work with sound reorganization (speech to text). i find good samples from google but i don't know how can i do so with Persian-Farsi language? i do it with English but how about Farsi? is it need some setting in my mobile android phone? is there anyone who do so?
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
startActivityForResult(intent, REQUEST_CODE);
just put new extra in your intent as below
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "fa");

Non-default language for voice recognition in Android TV

I'm unable to force custom Android TV application to recognise non-default language from voice-input. Same problem are in built-in YouTube application (and other). However it works in built-in Google Search app (Katniss).
There are my code which works well on Nexus phone, but on Nexus Player setting custom language doesn't give any results in selected language.
SpeechRecognizer sr = SpeechRecognizer.createSpeechRecognizer(this);
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,"voice.recognition.test");
String loc = "ru-RU";
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, loc);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, loc);
intent.putExtra(RecognizerIntent.EXTRA_ONLY_RETURN_LANGUAGE_PREFERENCE, loc);
intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS,5);
sr.startListening(intent);
Looks like it was fixed in one of Google Search app updates

Difference between ACTION_WEB_SEARCH and EXTRA_WEB_SEARCH_ONLY

I'm implementing speech recognition in my app and have some questions the API doc couldn't solve. I wonder what's the difference between using
Intent recognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);
and
Intent recognizerIntent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH);
?
I also recognized that I have to put the EXTRA_LANGUAGE_MODEL also when using ACTION_WEB_SEARCH? Why is that?
And what means EXTRA_WEB_SEARCH_ONLY? I thought that it is always web search with the web search action.

Android Google Voice Search changed language automatically sometimes

I have successfully added Google Voice Search Activity using following code:
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, "en-US");
try {
startActivityForResult(intent, 1);
} catch (ActivityNotFoundException a) {
Toast t = Toast.makeText(context, "Oops! Your device doesn't support Speech to Text",Toast.LENGTH_SHORT);
t.show();
}
I searched in "en-US" and its worked perfectly but sometimes it is searching like english of German or other countries and returning Pure ENGLISH WORDS. and not recognize my language.
Is there any SETTINGS that makes my search better.
Your help would be appreciated.

Send messages through Voice Recognition?

I used the following code to send a message "hello" when I say send.
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, getClass().getPackage().getName());
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, metTextHint.getText().toString());
startActivityForResult(intent, VOICE_RECOGNITION_REQUEST_CODE);
In onActivityResult() :
if(textMatchList.get(0).contains("send")) {
Intent smsIntent = new Intent(Intent.ACTION_VIEW);
smsIntent.putExtra("sms_body", "Hello");
smsIntent.putExtra("address", "0123456789");
smsIntent.setType("vnd.android-dir/mms-sms");
startActivity(smsIntent);
}
How can I make the app be more flexible. I mean for example if I say "Send this message to mike, Hey man, you want to go to the movie." How can I make the app use only the important information like Send, Mike, and the message itself. And then send the message as usual. Also how make this all possible without hard-coding it.
Are there any tutorials which do this on the net, if so please give me a link, I would really appreciate that.
Thank You
Maybe you might get the text of the recognized speech and use
if(text.contains("Mike")){
//send message to Mike (which i dont know how to do it,i am searching for this )
}

Categories

Resources