How to Play Audio using Corona SDK ?

Hi,

For playing audio – background music or sound effects – using Corona SDK, do the following,

1. Load the audio stream (background music or sound effects)

 backgroundMusic = audio.loadStream("bgm.mp3") 

2. Play the audio

backgroundMusicChannel = audio.play( backgroundMusic, { channel=1, loops=-1, fadein=5000 }  )  

It will play the background music on channel 1, loop infinitely, and fadein over 5 seconds. Loop 1 will set it to play once!
:)

Text to speech in ANDROID, A Simple Example.

Hello everyone……..

In this simple example I will show you how to use Text To Speech in ANDROID. This is one of the unique features in ANDROID.
Unlike iPhone , ANDROID has a built in TTS Library which supports many languages. But iPhone doesn’t have this feature. They have to depend on third-party software for implementing this.

Now go on create a fresh project and copy this following code to it.

package com.TTS;
import java.util.Locale;
import android.app.Activity;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;

public class TTS extends Activity implements TextToSpeech.OnInitListener {

	  TextToSpeech tts;
	  @Override
	  public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.main);
	    tts = new TextToSpeech(this,this);
	  }

	  public void onInit(int status) {
	    Locale loc = new Locale("eng", "","");
	    if(tts.isLanguageAvailable(loc) >= TextToSpeech.LANG_AVAILABLE){
	      tts.setLanguage(loc);
	    }
	    tts.speak("Text to speech in ANDROID from coderzheaven, Hope you like it.", TextToSpeech.QUEUE_FLUSH, null);
	  }

	  @Override
	  protected void onDestroy() {
	    super.onDestroy();
	    tts.shutdown();
	  }
}

After running this application you will hear the sound that is given as text in this line.

tts.speak(“Text to speech in ANDROID from coderzheaven, Hope you like it.”, TextToSpeech.QUEUE_FLUSH, null);

Please leave your comments if this post was useful.