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.
Related
I would like to use android's speechRecognizer to recognize sounds, which are not just words but any syllables (for example a baby saying "ba"/"ma").
This seems to be possible in python using the speech_recognition module, but I can't find a way to do so in java.
The code skeleton I have so far is as follows:
final Intent speechRecognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
speechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
speechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault());
speechRecognizer.startListening(speechRecognizerIntent);
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
When I want to share basic plaintext in my app, the option to copy it in my clipboard does not show up in the chooserlist. Is there something wrong with my code? Or has my device a wrong setup?
String code = getXMLCode();
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, code);
startActivity(Intent.createChooser(sharingIntent, getString(R.string.shareXMLCode)));
public String getXMLCode(){...}
Android does not have a "copy to clipboard" option as part of ACTION_SEND. Certain apps, like Google Drive, might offer such a feature.
cketti recently wrote a blog post about how you can add your own "copy to clipboard" option to your own ACTION_SEND requests. In a nutshell, you use EXTRA_INITIAL_INTENTS to add another option to the chooser, one that points to your own activity that will offer "copy to clipboard".
I'm about to launch my first app in a week,and want to know if google play automatically adds the shortcut to the home-screen or is it something if have to do with code. I have question like this but there's nothing about creating shortcut on install.
I launched my app found that Google Play does automatically creates a shortcut on the homescreen and we don't have to do it in our code,although i don't know if it works the same way in Amazon app store. hope this helps someone who is trying to find answer to the same question.
Mohit Madaan's answer was correct. Just don't forget to set duplicate to false otherwise you might have several shortcuts:
addIntent.putExtra("duplicate", false);
put this permission in manifest
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
below for creating the shortcut icon on android Homescreen
private void ShortcutIcon(){
Intent shortcutIntent = new Intent(getApplicationContext(), MainActivity.class);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
Intent addIntent = new Intent();
addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "Test");
addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(getApplicationContext(), R.drawable.ic_launcher));
addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
getApplicationContext().sendBroadcast(addIntent);}
I came across this and I hope this helps you. http://viralpatel.net/blogs/android-install-uninstall-shortcut-example/
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