如何在应用程序中创建语音活动?

时间:2012-10-18 07:54:49

标签: android gridview voice

我正在为孩子们创建一个新的应用程序。这个应用程序是为孩子们学习字母表。

现在我已经创建了一个主屏幕,其中使用GridView显示字母表。现在我想要的是,当点击特定的字母表时,它应该转到该屏幕的下一个屏幕,它应该使用线条绘制字母表,然后应该添加类似(Apple的“A”)的声音?

是否有人知道如何做到这一点请帮助我...

提前致谢...

1 个答案:

答案 0 :(得分:1)

试试这个:

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!");    
相关问题