Is there some settings I have to change in the android emulator? The app runs in the android device but doesnt run in the simulator. When I press the convert button it just doesn't output any speech at all. I even checked if other apps give output through the speaker. Yes, youtube works perfectly fine.
package com.example.labpgm7;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import java.util.Locale;
public class MainActivity extends AppCompatActivity {
EditText texttospeak;
Button speak;
TextToSpeech t;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
texttospeak=findViewById(R.id.texttospeech);
t=new TextToSpeech(this, new TextToSpeech.OnInitListener() {
@Override
public void onInit(int status)
{
}
});
}
public void speak(View v)
{
String text=texttospeak.getText().toString();
t.setPitch(1.0f);
t.setSpeechRate(1.0f);
t.speak(text,TextToSpeech.QUEUE_FLUSH,null);
}
}