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);
Related
how can i confirm a setup intent for stripe in a Fragment now that onActivityResult has been deprecated and replaced with activity result launcher? How do you pass that to stripe? Where do i need to add stripe.onSetupResult?
ConfirmSetupIntentParams confirmParams = ConfirmSetupIntentParams
.create(paymentMethodParams, clientSecret);
stripe.confirmSetupIntent(this, confirmParams);
Stripe has revised the docs regarding Android development to use the newer launcher methods. This appears to be a large enough change that it’s not as simple as changing one function call for another. Take a look at the new docs here:
https://stripe.com/docs/payments/save-and-reuse?platform=android&ui=payment-sheet#android-collect-payment-details
The change to the SDK is pretty significant. In order to dig into the changes try reviewing the this PR.
https://github.com/stripe/stripe-android/commit/8b77ca2487a01f786cf845e5f644b98460036708
When I look at the StripeIntentActivity.kt I can see on line 160 they revised the stripe.confirmSetupIntent to use paymentLauncher.confirm instead. I think the code changes there might help you figure out how to reconfigure your Fragment.
In my app I want to scan a GS1-128 barcode, and need the FNC1 characters passed from the ZXing barcode scanner.
Right now I just receive the plain text without the FNC1 characters.
Is there a way to pass the DecodeHintType.ASSUME_GS1 via Intent to the scanner app?
I don't want to include the complete scanner source in my app and rather use the Intent.
In the source code of the scanner I can see that the DecodeHintType needs to be set to achive that:
https://code.google.com/p/zxing/source/browse/trunk/core/src/main/java/com/google/zxing/oned/Code128Reader.java
boolean convertFNC1 = hints != null && hints.containsKey(DecodeHintType.ASSUME_GS1);
Thanks for any help.
I searched almost the whole web and didn't find an answer to this.
This is driving me nuts...
At the end it turned out that it was easier than I thought:
intentScan.putExtra("ASSUME_GS1", true);
The hints can be set with extras.
I just had to figure it out, because I couldn't find it anywhere how to do that.
I downloaded the code of the Barcode Scanner and did a little debugging.
But now I can use the original app and get the barcode via Intent. :-)
Yes, that's the hint you need. It will return FNC1 as ASCII 29. There's not a general way to pass the hints by Intent, but some are supported as additional Intent extras. If you want to submit a patch that triggers this hint I'll take a look.
I'm trying to set the language of my TextToSpeech-object to Dutch. This is the default language of my Android tablet on which the app will run, and when I log Locale.getDefault() I get "nl_NL"so this is correct.
I've read that for TTS you need to supply the ISO Language Code and ISO Country Code when setting the language with Locale. But here is the problem: when the tablet does not have an Internet connection, the TTS doesn't seem to be able to set the language to Dutch. Here is my code for setting the language:
int result = tts.setLanguage(new Locale(Locale.getDefault().getISO3Language(),
Locale.getDefault().getISO3Country()));
// this equals to "nld","NLD"
if (result == TextToSpeech.LANG_MISSING_DATA
|| result == TextToSpeech.LANG_NOT_SUPPORTED)
{
tts.setLanguage(Locale.UK);
}else{
dutch = true;
}
Without Internet connection, the language is always set to Locale.UK. With Internet connection, it works as intended and the language is set to Dutch (I don't even have to provide the ISO-notation, just new Locale("nl_BE") or "nl_NL" will do).
Further in my code when the TTS.speak is called I always check if Dutch is true, and then a Dutch string is providedfor the speak method, otherwise an English string is provided.
How can I fix this that I can set the TextToSpeech language to Dutch without Internet connection?
EDIT: for other people experiencing my issue, check out the edited part of my answer below.
After a lot of research it seems that the standard languages that are installed with TTS do not contain the Dutch language.
I ran some test using the method isLanguageAvailable(Locale loc) and thereby checking for Dutch language etc., and it seems that the Dutch language is not supported (the returned value is LANG_NOT_SUPPORTED ).
I'll have to find another TTS-client to meet my needs or to play .mp3-files with the correct message (this could work because the values that the TTS had to pronounce were predefined).
Some links that helped me:
http://igordcard.blogspot.be/2014/02/changing-android-text-to-speech-tts.html
Missing languages in TTS android
How to check if a specific language data for Text to Speech(TTS) is installed on a device?
http://code.tutsplus.com/tutorials/android-sdk-using-the-text-to-speech-engine--mobile-8540
And an image showing which languages were installed:
EDIT: after updating the "Google TTS"-app from Google Play Store, Dutch BECAME available. If you're looking for Dutch offline TTS and you're using the Google TTS for it, just update it to the latest version.
Try
tts.setLanguage(new Locale("nl", "NL"));
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.
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