Read Aloud not working in XE16 GDK app - android

I had a read aloud menu option which was working fine with the API 15. But fails to work in the API 19. There is no error as such in the code but clicking on the menu doesn't lead to anything. Here is the code:
I have added this in the onCreate
mSpeech = new TextToSpeech(this, new TextToSpeech.OnInitListener() {
public void onInit(int status) {
if(status == TextToSpeech.SUCCESS)
result=mSpeech.setLanguage(Locale.US);
if(result==TextToSpeech.LANG_MISSING_DATA ||
result==TextToSpeech.LANG_NOT_SUPPORTED){
Log.e("error", "This Language is not supported");
}
}
});
And this is the code i run when the menu is clicked:
case R.id.read_aloud_menu_item:
System.out.println("goes into read aloud case");
System.out.println(TextToSpeech.ERROR);
mSpeech.speak("Hello, this is a sample data", TextToSpeech.QUEUE_FLUSH, null);

Related

Text to Speech(TTS) - Android - Portuguese

I'm trying to reproduce some text with an android aplication that will help visually impaired people, most especially with TTS, but in my case I need Portuguese-Brazil speaking, and the TTS class does not have Portuguese available as locale. Does anyone have any idea how to implement a Portuguese Brazil reader?
I'm using Android Studio, and MinSDK is 15.
...
tts = new TextToSpeech (this, this);
tts.setLanguage(Locale.[X]);
...
tts.speak("Muito obrigado a todos!", TextToSpeech.QUEUE_FLUSH, null);
...
How did you make your onInitListener()? When you call tts = new TextToSpeech (this, this); onInitListener() will connect TextToSpeech service to your tts instance. So, if you try to set language or speak sound, check this value:
tts = new TextToSpeech (this, this);
#Override
public void onInit(int status) {
if (status == TextToSpeech.SUCCESS) {
int res = tts.setLanguage(Locale.[X]);
if (res >= TextToSpeech.LANG_AVAILABLE) {
// Then, you can speak with your locale.
// Call speak() in here or after this method.
tts.speak("Muito obrigado a todos!", TextToSpeech.QUEUE_FLUSH, null);
}
}
}
Solved! My problem was that on the device was not installed TTS. So, just installed it from the google store(https://play.google.com/store/apps/details?id=com.google.android.tts&hl=en).

how to check TTS already support by device android?

I am designing an APP in Android using the TTS Engine.
As the first time, I tried to send the text to google then receive the audio from google via internet, and it is working well.
The next step is to play the TTS audio offline.
That means that I have some text, my Application will get the audio from the system, without connecting to internet.
I have implemented this:
Voice Recognition and Text to Speech
But my problem is TextToSpeech.LANG_MISSING_DATA: this is not working without internet.
If internet is not available, it is not working.
Please help me.
Check out Sifat Ifty's implementation at Text to speech(TTS)-Android
specifically the code block:
tts=new TextToSpeech(MainActivity.this, new TextToSpeech.OnInitListener() {
#Override
public void onInit(int status) {
// TODO Auto-generated method stub
if(status == TextToSpeech.SUCCESS){
int result=tts.setLanguage(Locale.US);
if(result==TextToSpeech.LANG_MISSING_DATA ||
result==TextToSpeech.LANG_NOT_SUPPORTED){
Log.e("error", "This Language is not supported");
}
else{
ConvertTextToSpeech();
}
}
else
Log.e("error", "Initilization Failed!");
}
});
This TextToSpeech.OnInitListener attempts to initialize the tts service if available. Remember to stop the tts service when you are done with it as well!

Android textToSpeach not working for me

I am trying to test the TextToSpeach engine using the tutorial from here:Android TextToSpeach tutorial
My setup is AndroidStudio and I use a real device for testing the result.
So my app compiles fine, opens on my device just fine, I enter a text there and click on the button, but nothing happens.
No sound can be heard besides the click sound of the button
No error shows in the LogCat
No Toast is showing on my device
I have volume set on the tablet (so it's not that)
I tryed to change the tutorial to make it say a specific sentence (to avoid the editBox) still nobody talks
What is wrong here? Do I need some permissions set for this app to work properly? I assume I would get an error somewhere if that were so...
Please help.
Implement your main Activity class from TextToSpeech.OnInitListener
public class AndroidTextToSpeechActivity extends Activity implements
TextToSpeech.OnInitListener
Initialization
tts = new TextToSpeech(this, this);
btnSpeak = (Button) findViewById(R.id.btnSpeak);
txtText = (EditText) findViewById(R.id.txtText);
Button on click event
btnSpeak.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View arg0) {
speakOut();
}
}) ;
On Init
#Override
public void onInit(int status) {
if (status == TextToSpeech.SUCCESS) {
int result = tts.setLanguage(Locale.US);
if (result == TextToSpeech.LANG_MISSING_DATA
|| result == TextToSpeech.LANG_NOT_SUPPORTED) {
Log.e("TTS", "This Language is not supported");
} else {
btnSpeak.setEnabled(true);
speakOut();
}
} else {
Log.e("TTS", "Initilization Failed!");
}
}
private void speakOut() {
String text = txtText.getText().toString();
tts.speak(text, TextToSpeech.QUEUE_FLUSH, null);
}
More Refrence :
http://www.androidhive.info/2012/01/android-text-to-speech-tutorial/
For Me its Working Well -Api Level 19

How to change text to voice engine in android from english to urdu?

I am working on project in which I need voice into urdu. So any one can tell me how I can change this voice?
Thanks
public void onInit(int status) {
xy.setPitch(1);
if (status == TextToSpeech.SUCCESS)
xy.speak("this is text to speech in engish" +
" ", TextToSpeech.QUEUE_ADD, null);}
It is either:
tts.setLanguage(new Locale("ur"));
Or:
tts.setLanguage(new Locale("urd"));
Used this link to find out.
there are two option to do that.
1- goto androd setting and change your language to URDU
2- tts.setLanguage(new Local("urd"));
t1=new TextToSpeech ( getApplicationContext (), new TextToSpeech.OnInitListener () {
#Override
public void onInit(int status) {
if(status != TextToSpeech.ERROR) {
t1.setLanguage(new Locale("ur"));
}**strong text**

Android Text-To-Speech Configuration and Variations

I am currently developing an app that makes intensive use of Text-To-Speech (I am using android.speech.tts.TextToSpeech) I have been able to integrate TTS in my voice and at present, a default American US voice is what reads aloud my text.
I would like to know how to make configurational changes to the speech engine. For example, I would like to reduce the speed at which the text is being read, swap between male and female voices and even provide support for different languages. Can anyone please help me with this information. Thanks in Advance :)
[Below is the code I am currently using (courtesy: a very well written basic blog on android TTS), all variable have been declared I am not copying the entire code, and this code snippet works just fine.]
btnSpeak = (ImageButton) findViewById(R.id.ttsIB);
btnSpeak.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View arg0) {
speakOut();
}
});
#Override
public void onDestroy() {
// to shutdown TTS
if (tts != null) {
tts.stop();
tts.shutdown();
}
super.onDestroy();
}
#Override
public void onInit(int status)
{
if (status == TextToSpeech.SUCCESS)
{
int result = tts.setLanguage(Locale.US);
if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED)
{
Log.e("TTS", "This Language is not supported");
}
else
{
btnSpeak.setEnabled(true);
speakOut();
}
}
else
{
Log.e("TTS", "Initilization Failed!");
}
}
private void speakOut()
{
String text = textVal.getText().toString();
tts.speak(text, TextToSpeech.QUEUE_FLUSH, null);
}
I've worked with TTS a couple of years ago and remember, that there were not so much configuration possibilities.
There is a useful method setEngineByPackageName(String packageName).
Some TTS engines have separate package names for every voice. For example, with Loquendo you need to write tts.setEngineByPackageName("com.loquendo.tts.susan") and your app will speak with US voice Susan.
But some TTS engines has common application and voices as plugins. So, you can configure it only this way:
tts.setEngineByPackageName("com.svox.pico");
tts.setLanguage(Locale.US);
If there are several US voices for this engine, your application will speak with default (selected in phone preferences)

Categories

Resources