Android Google Voice Search changed language automatically sometimes - android

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.

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");

Android - Voice recognition

I am looking for a voice recognition library for Android. I only need it to understand "Yes/No" answers ( in different languages - like English, German, French ).
Any suggestions?
Not sure about V-R libraries because the Play Store max App size is 50megs and those voice packages are about 15 to 20 megs each so it will impossible to include multiple languages directly into the App.
There may be an online service to use but you need to search the net for that.
What most people use is the inbuilt Android voice recognition Intent. For different languages should be ok for the ones you want as they are included. However i'm not sure if for example in France when you buy a phone or a tablet the default V-R language will be French and not English, therefore the user will need to go into Language settings and Download the French V-R package.
To start V-R in Android you do
startVoiceRecognitionActivity();
private void startVoiceRecognitionActivity() {
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, getClass().getPackage().getName());
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 1);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en-US");
startActivityForResult(intent, 1234);
}
//To get the Voice data back as Text string
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK) {
//pull all of the matches
ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
String topResult = matches.get(0);
}};
The String topResult is the speech in text

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

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 )
}

Speech recognition , unknown error issue in 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.

Categories

Resources