My current code below works fine when using the "ZH" ISO code for Mandarin but won't for Cantonese. This is the code below
Intent i = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
String myLanguage= "yue";
i.putExtra(RecognizerIntent.EXTRA_LANGUAGE, myLanguage);
i.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, myLanguage);
i.putExtra(RecognizerIntent.EXTRA_ONLY_RETURN_LANGUAGE_PREFERENCE, myLanguage);
I got the code working, the dash just needed replaced with a underscore to make:
zh_HK
Thanks for your help Lilz.
For Cantonese
try zh-HK instead
Hope this helps
Related
I want to output the speech to traditional chinese but it output to simplify chinese instead. My codes:
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "zh-TW");
I also tried to set EXTRA_LANGUAGE to "zh_TW", "TW" and Locale.TAIWAN but it doesn't work too.
In my Android 7.0 settings "Traditional Chinese"(繁體中文) is added in Language preferences. I able to select it in keyboard & type it.
Is this a bug of google speech recognizer?
Finally I found the solution, need to use
cmn-Hant-TW for EXTRA_LANGUAGE.
Google documentation is sucks.
I want to support my app to multiple languages.I implemented for static strings through localization but what i want is if user change app language from English to any other and input Edit text with google voice then that string will b shown in user selected language rather than English language. As in google translate app happens,i input text by voice and what result is found that string is in that selected language.
Can anyone please help me??
There is limited supported language but you need to invoke Speech Recognition by putting extra intent parameter
private void listen() {
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
//Specify language
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.SIMPLIFIED_CHINESE)
// Specify language model
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
// Specify how many results to receive
intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 5);
// Start listening
startActivityForResult(intent, SR_CODE);
}
check full answer
So I'm pretty new to the whole Android Studio thing and I've been using the internet to help me with a lot of the things I am doing and needed help on something.
I'm not sure if it's possible to connect this to either a string or an SQL database but I have a Main Layouts with a bunch of buttons that allow me to click on them and choose what external player I would like to use to watch the video. In my MainActivity java class, this is how it finds the button.
case R.id.button3:
intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("http://videoname.mp4"), "video/*");
startActivity(Intent.createChooser(intent, "Choose an External Player"));
break;"
I wanted to know if "http://videoname.mp4" url can be connected to like a string where I can always update or change the URL instead of manually going to find the URL in the MainActivity java and changing it. As of now I have to manually do it but a different way to do it would be helpful.
I'm sorry if it's all confusing, but if you know, please let me know as soon as.
Thank you.
you just need write your string URL :
open your directory folder /res/values/strings.xml -> write your string : <string name="yourStringName>yourStringURL</string>. to use your string do this
getContext().getString(R.string.yourStringName) in fragment
getString(R.string.yourStringName) in Activity
or you can write directly on your code, put your cursor on your string, then press key alt + enter choose extract string resource fill the resource name with your string name
wherever you need to use it, just do point 1 or 2. also in your Intent
hope this help you, never stop learning!
Add it to strings.xml in your project. That is the recommended way of using strings anyway.
I'm developing a ImageJ plugin that It works in my desktop pc but in my laptop it doesn't.
For this reason, now I'm trying to improve and I want to modify the next steps but i can't get it. This is the code:
IJ.selectWindow("example");
IJ.run("Convert to Mask");
IJ.run("Fill Holes");
IJ.run("Set Scale...", "distance=1 known="+pixelSize+" pixel=1 unit=um");
IJ.run("Analyze Particles...", "size=0-Infinity circularity=0.00-1.00 show=Masks display clear record");
I known that "Analyze Particles" I must to use the ParticleAnalyzer class (I dont sure how to do but... I'm researching the class) but for the other steps I can not find solution.
I hope that someone can help, thank you.
Best Regards.
I didn't get what I wanted it but I left to use the windows and now I am using ImagePus variables and It works better. I put the code:
IJ.run(this.cMask, "Convert to Mask", "");
IJ.run(this.cMask, "Fill Holes","");
IJ.run(this.cMask, "Set Scale...", "distance=1 known="+pixelSize+" pixel=1 unit=um");
IJ.run(this.cMask, "Analyze Particles...", "size=0-Infinity circularity=0.00-1.00 display clear record");
I have a requirement to pass the text "English (United States)" into a text box. But when I am using the below command:
driver.findElement(By.id("defaultLang")).sendKeys("English (United States)");
It is entering only "English United States) into the text box. the Open Parentheses is missing when WebDriver is writing the text into the textbox.
By using this you can enter the left parenthesis in text box.
String a = (Keys.chord(Keys.SHIFT,"9"));
String b = "AAA";
String c = "BBB)";
driver.findElement(By.id("ID")).sendKeys(b+a+c);
Resultant O/P is : AAA(BBB)
You should use escape to send special characteres in selenium web driver,
I think you can try something like this :
driver.findElement(By.id("defaultLang")).sendKeys("English \(United States\)");
I hope it may help you
This looks like a known bug. See issue 6822 here.
What you can do now, is to set it by injecting JavaScript directly.
// untested Java code, provides only the logic, you need debug yourself
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].setAttribute('value', arguments[1]);", driver.findElement(By.id("defaultLang")), "English (United States)");