The constructor for TextToSpeech is supposed to look like this:

 TextToSpeech(Context context, TextToSpeech.OnInitListener listener)

So when you create it inside your new class, you need to pass it what
it wants.

- dave
www.androidbook.com

On Aug 16, 3:25 pm, Filip Havlicek <havlicek.fi...@gmail.com> wrote:
> Try to build your classes more like in this example:
>
> http://android-developers.blogspot.com/2009/09/introduction-to-text-t...
>
> 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 <anthony...@gmail.com>
>
> > 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 android-developers@googlegroups.com
> > To unsubscribe from this group, send email to
> > android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com>
> > 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to