设置文本的土耳其语语音 [英] set turkish language for text to speech
本文介绍了设置文本的土耳其语语音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在研究文本到语音应用程序,我想将土耳其语设置为:
Im working on text to speech app , i want to set turkish language to be as this:
tts.setLanguage(Locale.TR);
但是这在android中不可用,是这种添加方式错误还是存在将土耳其语言添加到语音文本的另一种方法.
BUT this is not available in android , is it wrong to add this way or there is different way to add turkish language to text to speech .
任何帮助和建议将不胜感激
any help and advice will be appreciated
文本到语音代码:
public class AndroidTextToSpeechActivity extends Activity implements
TextToSpeech.OnInitListener {
/** Called when the activity is first created. */
private TextToSpeech tts;
private Button btnSpeak;
private EditText txtText;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tts = new TextToSpeech(this, this);
btnSpeak = (Button) findViewById(R.id.btnSpeak);
txtText = (EditText) findViewById(R.id.txtText);
// button on click event
btnSpeak.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
speakOut();}
});}
@Override
public void onDestroy() {
// Don't forget to shutdown!
if (tts != null) {
tts.stop();
tts.shutdown();}
super.onDestroy();}
@Override
public void onInit(int status) {
// TODO Auto-generated method stub
if (status == TextToSpeech.SUCCESS) {
int result = tts.setLanguage(Locale.US);
// tts.setPitch(5); // set pitch level
// tts.setSpeechRate(2); // set speech speed rate
if (result == TextToSpeech.LANG_MISSING_DATA
|| result == TextToSpeech.LANG_NOT_SUPPORTED) {
Log.e("TTS", "Language is not supported");
} else {
btnSpeak.setEnabled(true);
speakOut();}
} else {
Log.e("TTS", "Initilization Failed");}}
private void speakOut() {
String text = txtText.getText().toString();
tts.speak(text, TextToSpeech.QUEUE_FLUSH, null);}}
推荐答案
如果您的设备是土耳其语,请使用:
if your device is Turkish, use :
tts.setLanguage(Locale.getDefault());
代替
int result = tts.setLanguage(Locale.US);
然后EXTRA_LANGUAGE_MODEL的值必须为:"tr-TR".
Then EXTRA_LANGUAGE_MODEL value must be: "tr-TR".
我尝试并成功.(但我还从三星市场下载了土耳其语lang.pack)
I tried and succeeded.(But I also downloaded Turkish lang.pack from samsung market)
这篇关于设置文本的土耳其语语音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文