How better is text-to-Speech in my android app, not respecting the punctuation marks?

Asked

Viewed 235 times

0

app already speaks what I write, but if I write a question with punctuation mark (?) does not pronounce as a question, the pronunciation is very fast, how do I improve it?

public class MainActivity extends AppCompatActivity implements TextToSpeech.OnInitListener {
private TextToSpeech TTS;
private Button BTN;
private EditText EDT;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    TTS = new TextToSpeech(this,this);
    BTN = findViewById(R.id.btn_ouvir_texto);
    EDT = findViewById(R.id.edt_input_txt);

    BTN.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            SpeechOut();
        }

    });
}

    @Override
    public void onInit(int status) {
    if(status == TextToSpeech.SUCCESS)
    {
        int result = TTS.setLanguage(Locale.getDefault());
        if(result == TextToSpeech.LANG_NOT_SUPPORTED || result ==TextToSpeech.LANG_MISSING_DATA)
        {
            Log.e("TTS", "Idioma não suportado");
        }else{
            BTN.setEnabled(true);
            SpeechOut();
        }
    }else {
        Log.e("TTS","Inicialização falhou...");
    }
}
    private void SpeechOut()
    {
        String text = EDT.getText().toString();
        TTS.speak(text,TextToSpeech.QUEUE_FLUSH,null);
    }

}

1 answer

1

The implementation of the TTS engine is the responsibility of your provider (system or store application) and may or may not support customization of the read parameters, so the read result can diverge considerably between devices.

Adjusting the voice intonation according to the score is a task that requires a robust TTS tool. According to some sources, the embedded version of Android supports a subset of SSML (markup language for voice synthesis), which can improve some aspects of reading, such as pauses between words. You should also consider using an online tool such as Google Cloud Text to Speech, which has a more comprehensive support of SSML.

I suggest reading of this answer (in English) in the OS.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.