Detect Language From RecognizerIntent - java

i write this code:
Intent voiceSearchIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
voiceSearchIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
startActivityForResult(voiceSearchIntent, 1);
i want to detect the language of speeched sentence. But when i run the intent it listens only English(US) language:
is possibile run the Intent in generic mode and retrieve the spoken sentence?
Thanks so much.

No, it's not possible. Speech reconition algorithm is designed in the way that it only works with a single language.
You have to create a language detection solution on your own, for example, you can run a handmade phonetic recognizer created with CMUSphinx and apply a classifier on a decoded sequence of phonemes to get a language. There are more advanced algorithm for language identification, see the review for initial links:
http://www.cslu.ogi.edu/HLTsurvey/ch8node9.html
It's not an easy task and it's definitely not robust. It's way easier to present user a list of languages to choose.

Related

How to implement decent "bad word filter"?

How can I create the good bad word chat filter? For example, let users not type Poop and send them warning.
However it should also filter pooopppp , P00p, Po0p, P0o0o0op, (or whatever trick they try to use) etc.
You should implement some Machine Learning to filter that. I recommend this : Google Tensorflow.
What you should do is to create the tensorflow engine, train them with bad words eg : Poop, P0op, Po0pp, etc... and after several training the engine will able to tell that Po0000p considered as bad word.
While Machine Learning might need steep learning curve, you can follow the tutorial at https://developers.google.com/machine-learning/crash-course/.

android Speech recognition API.System always recognizes default language

Here is how my code looks.
//loc will be either "ru-RU" or "en-US"
speechRecognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
speechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
speechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, loc);
speechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, loc);
speechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_ONLY_RETURN_LANGUAGE_PREFERENCE, loc);
Problem is that, when I am using the program with different phones it works well.But with my cell phone it always chooses default language. And rare times it is just mixing recognition languages. Like half of the result is in one language other half in another language.
I dont know whether it is cause of system or from code itself?
Plus It worked well before on my phone too. Can it be cause of some settings?
How can I overcome and fix it? I need to know to inform users how to fix it if they will have the same problem
How can I use voice recognition with other languages android
SpeechRecognizer with Google Search version 3.6.14.1337016 can't recognize other voice language except default
Firstly, the problem exists while using SpeechRecognizer
On this case only solution was to delete google search cause it is related to google search update. Doing so we will delete all updates. This worked on my own device
But on my opinion,actually, small updates should not change api behaviour. I hope there is programmatic way to solve this issue or there will be new update that will fix it
Here is undocumented programmatic solve:
intent.putExtra("android.speech.extra.EXTRA_ADDITIONAL_LANGUAGES", new
String[]{});
it is artetxem's answer
Other solution is just to call activity for recognition. This way google's dialog activity will be seen but there will be no language problems.
Issue opened by me issue
Issue opened on google search by artetxem issue
Hi #VSL i was also facing same problem to set language hindi instead of english, but Speech recognizer always take my Android OS default language which is english. But below code solved my problem
Intent recognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "hi");
recognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, InteractionActivity.this.getPackageName());
recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 3);
speech.startListening(recognizerIntent);

Identifying all the names from a given text

I want to identify all the names written in any text, currently I am using IMDB movie reviews.
I am using stanford POS tagger, and analysing all the proper nouns (as proper noun are names of person,things,places), but this is slow.
Firstly I am tagging all the input lines, then I am checking for all the words with NNP in the end, which is a slow process.
Is there any efficient substitute to achieve this task? ANy library (preferably in JAVA).
Thanks.
Do you know the input language? If yes you could match each word against a dictionnary and flag the word as proper noun if it is not in the dictionnary. It would require a complete dictionnary with all the declensions of each word of the language, and pay attention to numbers and other special cases.
EDIT: See also this answer in the official FAQ: have you tried to change the model used?
A (paid) web service called GlobalNLP can do it in multiple languages: https://nlp.linguasys.com/docs/services/54131f001c78d802f0f2b28f/operations/5429f9591c78d80a3cd66926

How can I use http://translate.google.com/ to translate the string in Java program?

I want to use http://translate.google.com/ to translate the string.
And now I want to sent a string from a java program in http://translate.google.com/ to translate the string from english to bangla .
And I want to get the translated string as a program output .
Anyone can tell me how can I do this......??
The wrong way to do that : use an HTTPClient to emulate, in Java, a browser request.
It's a bad way of using a website, as you'll make dirty things in HTTP, and your program will have to be modified each time Google modify the HTML pages on translate.google.com (even if that should be pretty rare).
The right way of doing that : use the Google Translate API provided by Google for that purpose. It's just a REST service so it works quite easily in JAVA.
Beware that the number of translations that you can do each day is, as far as i remember, limited to a certain amount each day (check the online conditions on the API website). At first glance after just checking that, it seems that the v2 API is not free anymore, i don't know if you can stick to the v1 one.
If google is not a must you can consider Bing translator. Here is a link on how to use the free APIs as well (the example uses C# but you can easily write the same in JAVA). We are using this in our project and it works quite well.
I used this code on my button for translate:
String translate = "translate this string";
String locale = Locale.getDefault().getLanguage();
Uri uri = Uri.parse("https://translate.google.com/#auto/"+ locale + "/" + translate); Intent intent = new Intent(Intent.ACTION_VIEW, uri);
getApplicationContext.startActivity(intent);
I used #auto to detect automatic from string translate, and locale to detect locale language from phone.
Hope this helps :)
Easy task.
Use this - http://translate.google.com/#{fromLanguage}|{toLanguage}|{your_string_here}
Just replace languages with yours (you can check it in translator - short names)
And add your string that you want to translate.
You can make request to this site

Is there a framework or cocoa API for playing video?

In short, I want to create a simple video player which can play some major video formats like quicktime *.mov, for example. What I need is:
video playback (at least the most major formats would be great)
play, pause
need information about where the movie currently is (how many seconds passed, or how much percent)
I'm targeting the mac, for the beginning. So the preferred technology is Cocoa and Objective-C. But if there's just nothing for that, I could also imagine to do something with Java. Any idea?
QTKit is the (built-in) Objective-C framework for developing with QuickTime. It includes QTMovieView and QTMovieLayer, an NSView and CALayer subclass respectively for playing any content that QuickTime understands. Simple playback controls can optionally be provided by these controls for free. Both can be used from Interface Builder, making a media app an almost zero-code affair. The QuickTime Programming Guide will get you started.
You should also check the QTKitPlayer sample code. It can do everything you describe and shows how to integrate all of the QTKit components for a playback-only application (QTKit also supports media capture and editing).
You can use QuickTime for Java
It's very easy to use.
Here's a snippet:
QTSession.open();
String url = "http://......mov";
DataRef dRef = new DataRef(url);
Movie mov = Movie.fromDataRef (dRef, StdQTConstants.newMovieActive);
MoviePlayer player = new MoviePlayer(mov);
mov.start();
JComponent qtPlayer = QTFactory.makeQTJComponent(player).asJComponent();
The snipped was taken from the examples from: Timing Framework written by Chet Haase
That sample ( the one from the Timing Framework ) looks like this:
Java quicktime http://img41.imageshack.us/img41/7268/capturadepantalla200909p.png
If you want to use Java then Java Media Framework or it's open source analog Freedom For Media in Java, will do the job. FMJ has native binding to DirectShow, QuickTime For Java and Gstreamer. It will do everything you need plus a little bit more. And you will not need to worry about which format you're playing.

Categories

Resources