I wrote successfully TTS with some references in Activity.
However, I want to call this TTS in my own class as below.

package pkg.BasicTTSinClass;
import android.speech.tts.TextToSpeech;

public class MyTTS {
        public TextToSpeech mTTS;
        public static void speak(String word)
        {
                mTTS = new TextToSpeech(this,this);     // it raised the error 
saying
"The constructor of TextToSpeech is undefined.
        }
}

=======================================
In Activity,

package pkg.BasicTTSinClass;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class BasicTTSinClass extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        ((Button)
findViewById(R.id.btnSpeak)).setOnClickListener(on_Speak);
        ((Button) findViewById(R.id.btnSpeak)).setEnabled(false);

    }

    private View.OnClickListener on_Speak = new View.OnClickListener()
{
        private EditText mWord;

                @Override
                public void onClick(View v) {
                         mWord = (EditText) findViewById(R.id.txtWord);
                         MyTTS.speak(mWord.getText().toString());
                }
        };

}




Can anyone help me write my own class for calling TTS?
It would be greatly appreciated.


Connie.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to