Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid widget Text to Speech not speaking
    primarykey
    data
    text
    <p>I referred to two links:</p> <ul> <li><a href="http://www.vogella.com/articles/AndroidWidgets/article.html" rel="nofollow noreferrer">Android Homescreen Widgets- Tutorial</a></li> <li><a href="https://stackoverflow.com/questions/3100246/starting-text-to-speech-engine-from-a-service">starting text to speech engine from a service?</a></li> </ul> <p>From these two links, I created an AppWidgetProvider class and a Service class like so:</p> <pre><code>public class HomeWidget extends AppWidgetProvider{ @Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { // TODO Auto-generated method stub super.onUpdate(context, appWidgetManager, appWidgetIds); ComponentName thisWidget = new ComponentName(context, HomeWidget.class); int[] allWidgetIds = appWidgetManager.getAppWidgetIds(thisWidget); Intent homeIntent = new Intent(context.getApplicationContext(), VoiceService.class); homeIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, allWidgetIds); context.startService(homeIntent); } } </code></pre> <p>the service:</p> <pre><code>public class VoiceService extends Service implements OnInitListener{ public static TextToSpeech mtts; private static final String LOG = "VoiceService"; @Override public IBinder onBind(Intent intent) { // TODO Auto-generated method stub return null; } @Override public void onCreate() { // TODO Auto-generated method stub super.onCreate(); Log.d(LOG,"Service created successfully!"); mtts = new TextToSpeech(getApplicationContext(),this); mtts.setLanguage(Locale.ENGLISH); } @Override public void onDestroy() { // TODO Auto-generated method stub super.onDestroy(); if(mtts!=null) { mtts.stop(); Log.d(LOG,"The service has been destroyed!"); } } @Override public void onStart(Intent intent, int startId) { // TODO Auto-generated method stub AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this .getApplicationContext()); int[] allWidgetIds = intent .getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS); ComponentName thisWidget = new ComponentName(getApplicationContext(), HomeWidget.class); int[] allWidgetIds2 = appWidgetManager.getAppWidgetIds(thisWidget); Log.w(LOG, "From Intent" + String.valueOf(allWidgetIds.length)); Log.w(LOG, "Direct" + String.valueOf(allWidgetIds2.length)); for(int widgetId : allWidgetIds) { Log.w(LOG,"inside for loop"); RemoteViews remoteViews = new RemoteViews(this .getApplicationContext().getPackageName(), R.layout.home_widget); mtts = new TextToSpeech(getApplicationContext(),this); mtts.setLanguage(Locale.ENGLISH); mtts.speak("This is the text to be spoken", TextToSpeech.QUEUE_FLUSH, null); Intent clickIntent = new Intent(this.getApplicationContext(),HomeWidget.class); clickIntent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE); clickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, allWidgetIds); PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, clickIntent, PendingIntent.FLAG_UPDATE_CURRENT); remoteViews.setOnClickPendingIntent(R.id.home, pendingIntent); appWidgetManager.updateAppWidget(widgetId, remoteViews); } stopSelf(); super.onStart(intent, startId); } @Override public void onInit(int status) { // TODO Auto-generated method stub } </code></pre> <p>I got the widget up and when I tap the widget, these 6 lines in logcat appears:</p> <pre><code>08-03 02:12:55.354: D/VoiceService(3666): Service created successfully! 08-03 02:12:55.358: W/VoiceService(3666): From Intent1 08-03 02:12:55.358: W/VoiceService(3666): Direct1 08-03 02:12:55.358: W/VoiceService(3666): inside for loop 08-03 02:12:55.358: I/TTS received:(3666): This is the text to be spoken 08-03 02:12:55.370: D/VoiceService(3666): The service has been destroyed! </code></pre> <p>But I'm not hearing anything. I've maxed the volume, ensured that it was using a speech synthesis engine(Pico TTS) and installed both English(United States) and English(United Kingdom) for it. I've also installed voice data required for speech synthesis. </p> <p>What else am I missing or doing wrong such that there isn't a voice being spoken?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload