Skip to content

set text to speech language #240

Open
@prilaga

Description

@prilaga

Hey guys @hrishikesh-kadam @mahavir155,
Thank you for the great library!

Can you add ability to change language of speech for the book.
Currently in the project all our books have the german language. But your app reader reads on english pronunciation.

Questions:

  1. How to set/change the language of text-to-speech? I see that Locale.UK is default.
  2. Can we disable the speech button in some cases?

I found that you set the language in MediaController on next method:

public void setTextToSpeech(final Context context) {
    mTextToSpeech = new TextToSpeech(context, new TextToSpeech.OnInitListener() {
        @Override
        public void onInit(int status) {
            if (status != TextToSpeech.ERROR) {
                mTextToSpeech.setLanguage(Locale.UK);
                mTextToSpeech.setSpeechRate(0.70f);
            }

            mTextToSpeech.setOnUtteranceCompletedListener(
                    new TextToSpeech.OnUtteranceCompletedListener() {
                        @Override
                        public void onUtteranceCompleted(String utteranceId) {
                            ((AppCompatActivity) context).runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    if (mIsSpeaking) {
                                        callbacks.highLightTTS();
                                    }
                                }
                            });
                        }
                    });
        }
    });
}

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions