Developer

TTS Speech Rate

RealWear has a custom implementation of Android’s standard TextToSpeechService. Our implementation allows developers to use the standard Android TTS API calls.

We have an example project that adjusts the speech rate of the TTS engine.  The GitHub repository is located at: GitHub - realwear/tts-rate-example: TTS Speech Rate sample app.

Inside of MainActivity.java, the TextToSpeech object is declared as follows:

TextToSpeech t1;

The TextToSpeech object is then initialized as follows:

t1 = new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(int status) {
                if (status != TextToSpeech.ERROR) {
                    t1.setLanguage(Locale.ENGLISH);
                }
            }
        });

There are three different methods that adjust the speech rates (as examples):

    /**
     * Sets the speech rate to normal (1.0)
     * @param view
     */
    public void rateNormal(View view) {
        t1.setSpeechRate(1.0f);
    }

    /**
     * Sets the speech rate to twice the normal rate (2.0)
     * @param view
     */
    public void rateFast(View view) {
        t1.setSpeechRate(2.0f);
    }

    /**
     * Sets the speech rate to half the normal rate (0.5)
     * @param view
     */
    public void rateSlow(View view) {
        t1.setSpeechRate(.5f);
    }

These methods use the standard TTS API call documented here: TextToSpeech  |  Android Developers

The following method then calls the speak method in the TTS API:

    public void testSpeak(View view) {
        String testSpeech = "test test test test test test test";

        t1.speak(testSpeech, TextToSpeech.QUEUE_ADD, null, "test");
    }