I want to save audio file in Arabic language. for that I am using the code as below.
i am trying it, but I am not able to save in Arabic language. its saves only in English language.
please help me, Thanks
package com.t;
import java.io.File;
import java.util.HashMap;
import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import android.speech.tts.TextToSpeech;
import android.speech.tts.TextToSpeech.OnInitListener;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
public class TextToSpeechNewActivity extends Activity {
Button store, play;
EditText input;
String speakTextTxt;
TextToSpeech mTts;
HashMap<String, String> myHashRender = new HashMap<String, String>();
String tempDestFile ;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
store = (Button) findViewById(R.id.button1);
play = (Button) findViewById(R.id.button2);
input = (EditText) findViewById(R.id.editText1);
store.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
speakTextTxt = input.getText().toString();
Log.v("log", ""+input.getText().toString());
myHashRender.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID,speakTextTxt);
String exStoragePath = Environment.getExternalStorageDirectory().getAbsolutePath();
File appTmpPath = new File(exStoragePath + "/pradip");
appTmpPath.mkdirs();
String tempFilename = input.getText().toString()+".wav";
tempDestFile = appTmpPath.getAbsolutePath() + "/"+ tempFilename;
new MySpeech(speakTextTxt);
}
});
}
class MySpeech implements OnInitListener{
String tts;
public MySpeech(String tts)
{
this.tts = tts;
mTts = new TextToSpeech(TextToSpeechNewActivity.this, this);
}
@Override
public void onInit(int status)
{
Log.v("log", "initi");
mTts.synthesizeToFile(speakTextTxt, myHashRender, tempDestFile);
}
}
}