Try to build your classes more like in this example:

http://android-developers.blogspot.com/2009/09/introduction-to-text-to-speech-in.html

And let us know if that helped. From a brief look it seems you might be
missing the TTS data on your device.

2010/8/16 Connie <[email protected]>

> 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]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
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