Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8218829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:56:08+00:00 2026-06-07T12:56:08+00:00

I am trying to create a Text to Speech app that will remember the

  • 0

I am trying to create a Text to Speech app that will remember the last sentence or part of the sentence after a comma where it was when the app is paused. Below is my code.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    pitch = (EditText) findViewById(R.id.pitch);
    words = (EditText) findViewById(R.id.wordsToSpeak);
    words.setText("This message is intended only for the use of the individual or entity to which it is addressed and may contain information that is privileged, confidential or exempt from disclosure by law.");
    speakBtn = (Button) findViewById(R.id.speak);

    // Check to be sure that TTS exists and is okay to use
    Intent checkIntent = new Intent();
    checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
    startActivityForResult(checkIntent, REQ_TTS_STATUS_CHECK);
}

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQ_TTS_STATUS_CHECK) {
        switch (resultCode) {
        case TextToSpeech.Engine.CHECK_VOICE_DATA_PASS:
            // TTS is up and running
            mTts = new TextToSpeech(this, this);
            Log.v(TAG, "Pico is installed okay");
            break;
        case TextToSpeech.Engine.CHECK_VOICE_DATA_BAD_DATA:
        case TextToSpeech.Engine.CHECK_VOICE_DATA_MISSING_DATA:
        case TextToSpeech.Engine.CHECK_VOICE_DATA_MISSING_VOLUME:
            // missing data, install it
            Log.v(TAG, "Need language stuff: " + resultCode);
            Intent installIntent = new Intent();
            installIntent
                    .setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
            startActivity(installIntent);
            break;
        case TextToSpeech.Engine.CHECK_VOICE_DATA_FAIL:
        default:
            Log.e(TAG, "Got a failure. TTS apparently not available");
        }
    } else {
        // Got something else
    }
}

@Override
public void onInit(int status) {
    // Now that the TTS engine is ready, we enable the button
    if (status == TextToSpeech.SUCCESS) {
        speakBtn.setEnabled(true);
        mTts.setOnUtteranceCompletedListener(this);

    }
}

public void doSpeak(View view) {
    mTts.setPitch(new Float(pitch.getText().toString()));

    StringTokenizer st = new StringTokenizer(words.getText().toString(),
            ",.");

    while (st.hasMoreTokens()) {

        params.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID,
                String.valueOf(uttCount++));
        mTts.speak(st.nextToken(), TextToSpeech.QUEUE_ADD, params);
    }

    // mTts.speak(words.getText().toString(), TextToSpeech.QUEUE_ADD, null);
};

@Override
public void onPause() {
    super.onPause();
    // if we're losing focus, stop talking
    if (mTts != null)
        mTts.stop();
}

@Override
public void onDestroy() {
    super.onDestroy();
    mTts.shutdown();
}

@Override
public void onUtteranceCompleted(String utteranceId) {
    Log.v(TAG, "Got completed message for uttId: " + utteranceId);
    lastUtterance = Integer.parseInt(utteranceId);

}

}

I am able to get get the android to speak and keep track of the token that it last spoke. However, I am not sure how to resume where it last left off when you press the speakBtn. Is there anyway to go back to a certain token within a tokenizer if all the tokens were not successfully read out loud?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T12:56:10+00:00Added an answer on June 7, 2026 at 12:56 pm

    How about:

    for(int i=0; i<successfulUtterances; ++i)
      tokenizer.nextToken();
    String nextUnspokenUtterance = tokenizer.nextToken();
    

    If you’re asking whether there’s a direct way, there isn’t. But this way will get rid of all the tokens you don’t need and let you carry on.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create coloumns of text for a C# app that will be
I'm trying create a box in my Django app that displays text (and possibly
I'm trying to create a speech to text app, to get started I got
I'm trying to create text in html, that once clicked, the the value of
I am trying to create a simple Javascript text editor that only makes paragraph
Trying to create Sublime Text environment in Netbeans IDE. The screen below is before
I am trying to create a text box that grows every time a letter
I am trying to create a text input field that converts the input text
I will try to keep this short. I'm trying to create boxes of text
I'm trying to create a text widget that includes an entry form on top

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.