You would help yourself by adding debugging so you can double check things.

What permissions do you have set?
What device are you testing on?
When a call comes in what happens?


On 10 August 2013 21:28, shiva pendem <[email protected]> wrote:

> HI every one,
>
> i would like to start a text to speech on a incoming call and i have tried
> the following method,
> private class CallStateListener extends PhoneStateListener implements
> TextToSpeech.OnInitListener{
>  public TextToSpeech tts;
>  @Override
> public void onCallStateChanged(int state, String incomingNumber) {
> boolean entered=false;
>                         tts = new TextToSpeech(ctx, new
> TextToSpeech.OnInitListener() {
> 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("TTS", "Language is not supported");
> } else {
> speakOut("Test");
> }
> } else {
> Log.e("TTS", "Initilization Failed");
> }
> }
> });
> switch (state) {
> case TelephonyManager.CALL_STATE_RINGING:
> // called when someone is ringing to this phone
> String text="";
> if(!entered)
> {
> Log.v("Test","incomingNumber is "+incomingNumber);
>  tts.speak("Hello "+getUserName()+" you have a call ",
> TextToSpeech.QUEUE_FLUSH, null);
> entered=!entered;
> }
> Toast.makeText(ctx,"Incoming: "+incomingNumber+"
>  "+text,Toast.LENGTH_LONG).show();
> break;
> case TelephonyManager.CALL_STATE_OFFHOOK:
> if(entered)
> {
> entered=!entered;
> }
> break;
> }
> }
> 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("TTS", "Language is not supported");
> } else {
> speakOut("Test");
> }
>
> } else {
> Log.e("TTS", "Initilization Failed");
> }
> }
> private void speakOut(String text) {
> tts.speak(text, TextToSpeech.QUEUE_FLUSH, null);
> }
> }
>
> I have initialized and used all the methods but unable to get the required
> output,
>
> Can any one tell me how can i overcome this issue and make the speech on a
> call with user defined message,
>
> If possible please advice me the jar that are used to convert text into
> speech with a simple method,while the phone was ringing,
>
> Thanks in advance,
> Shiva Shankar
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Android Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to