Example usage for android.speech.tts TextToSpeech getMaxSpeechInputLength

List of usage examples for android.speech.tts TextToSpeech getMaxSpeechInputLength

Introduction

In this page you can find the example usage for android.speech.tts TextToSpeech getMaxSpeechInputLength.

Prototype

public static int getMaxSpeechInputLength() 

Source Link

Document

Limit of length of input string passed to speak and synthesizeToFile.

Usage

From source file:ca.rmen.android.poetassistant.PoemAudioExport.java

void speakToFile(TextToSpeech textToSpeech, String text) {
    final File audioFile = getAudioFile();
    if (audioFile == null) {
        notifyPoemAudioFailed();//from  www . j  a  va2  s  .c  o  m
    } else {
        EventBus.getDefault().register(this);
        notifyPoemAudioInProgress();
        String textToRead = text.substring(0, Math.min(text.length(), TextToSpeech.getMaxSpeechInputLength()));
        Completable.fromRunnable(() -> deleteExistingAudioFile(audioFile)).subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(() -> speakToFile(textToSpeech, textToRead, audioFile));
    }
}