0

I am trying to implement Text-to-speech in my android auto app but unable to hear it on Desktop head unit. I have also tried it on Car Head unit but no luck.

below is the code i am using

 TextToSpeech tts=new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() {
     @Override
     public void onInit(int status) {
        if(status != TextToSpeech.ERROR) {
           t1.setLanguage(Locale.UK);
        }
     }
  });

and on button click i am using

 tts.speak(toSpeak, TextToSpeech.QUEUE_FLUSH, null);

also tried to turn OFF Bluetooth Headset as suggested in xda forums but still same issue.

Do i need to add any extra library like "gear.aar" to make it work for Auto as the code is in CarActivity

Community
  • 1
  • 1
Mahesh
  • 1,257
  • 1
  • 14
  • 24

2 Answers2

0

speak() method requires four parameters to execute the job I solved this using below code

 tts.speak(readText, TextToSpeech.QUEUE_ADD, null, ""+Calendar.getInstance().getTimeInMillis());
Mahesh
  • 1,257
  • 1
  • 14
  • 24
0

I had the same problem.

This is what should be done:

  • be sure you call tts.speak(...) after TTS is initialized (return 0 - SUCCESS)
  • turn off bluetooth on the computer