Hi

I'm trying to do a text to speech test application, seeing this tutorial: 
http://android-developers.blogspot.com.es/2009/09/introduction-to-text-to-speech-in.html

I tryed doing what the tutorial says, and i'm setting the language only to 
spanish: 

mTts = new TextToSpeech(this, this);
mTts.setLanguage(new Locale("spa"));

The problem is that when the app starts, the app prompts me to a screen 
asking me download four languages, GERMAN, SPANISH, FRENCH, ITALIAN. If i 
only download spanish language and then i press back key, the app works, 
but EACH TIME i start the app, it shows me the same screen to download the 
other three languages, and only stop appearing if i download the foru 
languages.

My objective is to prompt the user to download ONLY spanish, and to show 
the languages download dialog only one time, not allways.

I'm testing it on a Nexus S phone with 4.1

This is the full code:

public class MainActivity extends Activity implements OnInitListener {

    private static final int MY_DATA_CHECK_CODE = 0;
    EditText editText;
    Button button;
    private TextToSpeech mTts;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        editText = (EditText) findViewById(R.id.editText);
        button = (Button) findViewById(R.id.button);    

        editText.setText("Estoy probando, probando y probando, porque hay que 
probar.");

        Intent checkIntent = new Intent();
        checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
        startActivityForResult(checkIntent, MY_DATA_CHECK_CODE);        

         mTts = new TextToSpeech(this, this);
         mTts.isLanguageAvailable(new Locale("spa"));

        button.setOnClickListener(new OnClickListener() {           
            @Override
            public void onClick(View v) {
                mTts.speak(editText.getText().toString(), 
TextToSpeech.QUEUE_FLUSH, null);


            }
        });
    }

    protected void onActivityResult(int requestCode, int resultCode, Intent 
data) {
        if (requestCode == MY_DATA_CHECK_CODE) {
            if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) {
                // success, create the TTS instance
                mTts = new TextToSpeech(this, this);
                mTts.setLanguage(new Locale("spa"));
            } else {
                // missing data, install it
                Intent installIntent = new Intent();
                installIntent.setAction(
                    TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
                startActivity(installIntent);
            }
        }
    }

    @Override
    public void onInit(int arg0) {
        // TODO Auto-generated method stub

    }}

 

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to