我在做播音员的项目。我的TTS服务不提供内部服务。我的逻辑猫说它运行,但不会说。这是我的密码。请告诉我出了什么问题?我是从广播电台打来的。
public class Speaker extends Service implements TextToSpeech.OnInitListener {
public static TextToSpeech mtts;
@Override
public IBinder onBind(Intent arg0) {
return null;
}
@Override
public void onCreate() {
Log.d("SpeakerService", "Service created successfully!");
mtts = new TextToSpeech(getApplicationContext(), this);
mtts.setLanguage(Locale.ENGLISH);
}
@Override
public void onStart(Intent intent, int startid) {
Log.d("SpeakerService", "Service started successfully!");
Log.d("SpeakerService", "Service started successfully!");
// Log.d("SpeakerService", "tspker.mtts = " +
// TextSpeaker.mtts.toString());
mtts = new TextToSpeech(getApplicationContext(), this);
mtts.setLanguage(Locale.ENGLISH);
mtts.speak("The service has been done The service has been done",
TextToSpeech.QUEUE_FLUSH, null);
Toast.makeText(getApplicationContext(),
"The service has been done!", Toast.LENGTH_SHORT)
.show();
}
@Override
public void onDestroy() {
if (mtts != null) {
mtts.stop();
Toast.makeText(getApplicationContext(),
"The service has been destroyed!", Toast.LENGTH_SHORT)
.show();
}
}
@Override
public void onInit(int arg0) {
}
}发布于 2015-06-30 06:04:08
您必须在onInit中或在调用onInit之后调用onInit。
https://stackoverflow.com/questions/31127438
复制相似问题