Search code examples
androidgridviewvoice

How to create voice activity in application?


I am creating a new Application for kids. This application is for kids to learn alphabets.

Now I have created a main screen in which alphabets are shown using GridView . Now what I want is, when clicked on particular alphabets it should go to next screen in that screen it should draw an alphabet using lines and then a voice like ('A' for Apple) should be add?

Is any body know how to do that then please help me ...

Thanks in Advance...


Solution

  • try this one:

    TextToSpeech mTextToSpeech = new TextToSpeech(this,new TextToSpeech.OnInitListener()
    {
      @Override
      public void onInit(int status)
      {
        // TODO Auto-generated method stub
        if(status == TextToSpeech.SUCCESS)
        {
          // set language
          int supported = mTextToSpeech.setLanguage(Locale.US);
          if((supported != TextToSpeech.LANG_AVAILABLE)&&(supported != TextToSpeech.LANG_COUNTRY_AVAILABLE))
          {
            displayToast("dont support current language");
          }
        }
      } 
    });
    
    // start to speak
    mTextToSpeech.speak("A for Apple", TextToSpeech.QUEUE_FLUSH, null);  
    
    // store your voice to file
    int r = mTextToSpeech.synthesizeToFile(mEditText.getText().toString(), null, "/mnt/sdcard/speak.wav");
    if(r == TextToSpeech.SUCCESS) displayToast("save success!");