土耳其语中的Android是否有TTS API?
-
26-10-2019 - |
题
土耳其语中是否有适用于Android的免费TTS(文本到语音)服务?我在Google中没有发现任何有用的东西。
解决方案
我还没有在Android上尝试过,但是我最近发现了这一点: http://www.ispeech.org语音质量在Web应用程序上看起来很有希望。
试一试 :)
其他提示
在这里,您可以使用以下方式使用Google TTS:
strText = converToTurkishCharacter(strText);
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
textToSpeech = new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() {
@Override
public void onInit(int status) {
Locale locale = new Locale("tr_TR");//set Locale
textToSpeech.setLanguage(locale);
if (status != TextToSpeech.ERROR) {
}
if (status == TextToSpeech.SUCCESS) {
String[] text = strText.split("\\.");//split with every "dot"
for (int i = 0; i < text.length; i++) {
HashMap uttrerance = new HashMap();
uttrerance.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, Integer.toString(i));
textToSpeech.speak(text[i], 1, uttrerance);
}
}
//-------checks engine
List engineList = textToSpeech.getEngines();
for(Object strEngine : engineList){
Log.d("tagg",strEngine.toString());
if(strEngine.toString().equals("EngineInfo{name=com.google.android.tts}")){//check if google tts api engine is installed on device
isGoogleAvaible = true;
}
}
if(!isGoogleAvaible){
Toast toast = Toast.makeText(ActivityColumnistArticle.this,
"Google TTS Eksik...Lutfen yukleyin", Toast.LENGTH_LONG);
toast.setGravity(Gravity.BOTTOM, 0, 0);
toast.show();
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://details?id=com.google.android.tts"));
startActivity(intent);//user should install google tts , if it is defaultly not installed
}
//---------------For missing data
int code = textToSpeech.isLanguageAvailable(locale);
if (code == -2 || code == -1) {
Intent installIntent = new Intent();
installIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
startActivity(installIntent);
}
}
}, "com.google.android.tts");
}
else{
Toast toast = Toast.makeText(ActivityColumnistArticle.this,
"Ses destegi icin minumum Icecream Sandwich yuklu olmalı...", Toast.LENGTH_LONG);
toast.setGravity(Gravity.BOTTOM, 0, 0);
toast.show();
}
此外,Google tts具有带有türkish角色的错误,例如“Ö”,美,因此您应该用Unicode转换它们:
private String converToTurkishCharacter(String text){
text = text.replace("\u015f", "\u015f");
text = text.replace("\u00e7", "\u00e7");
text = text.replace("\u011f", "\u011f");
text = text.replace("\u0131", "\u0131");
text = text.replace("\u00fc", "\u00fc");
text = text.replace("\u00f6", "\u00f6");
// ----
text = text.replace("\u011e", "\u011e");
text = text.replace("\u0130", "\u0130");
text = text.replace("\u00d6", "\u00d6");
text = text.replace("\u00dc", "\u00dc");
text = text.replace("\u015e", "\u015e");
text = text.replace("\u00c7", "\u00c7");
return text;
}
某些Android设备仅具有PICO TTS,因此这就是为什么您检查Google TTS并要求用户安装...
不:为了正常工作,您应该拥有真实的Android设备
在我的情况下,我解决了这个问题
定义该变量:
最终语言环境= new Locale(“ TR”,“ TR”);
在OnCreate方法中:
tts = new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() { @Override public void onInit(int status) { if (status == TextToSpeech.SUCCESS) { int result = tts.setLanguage(locale); if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) { tts.speak("bir sorun oluştu", TextToSpeech.QUEUE_FLUSH, null); } } else { tts.speak("bir sorun oluştu.", TextToSpeech.QUEUE_FLUSH, null); Log.d(TAG, "Text to speech is not successful"); } } }); tts.speak("bağlanıyor", TextToSpeech.QUEUE_FLUSH, null);
它会说“bağlanıyor”
不隶属于 StackOverflow