我想用阿拉伯语保存音频文件。为此,我使用如下代码。
我正在尝试,但我无法以阿拉伯语保存。它仅以英语保存。请帮助我,谢谢
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);
}
}
}