Any TTS api for Android in turkish?
有没有土耳其版的Android免费TTS(文本到语音)服务?我在谷歌没有发现任何有用的东西。
我还没有在Android上尝试过,但我最近发现了一个:http://www.ispech.org网络应用程序的语音质量看起来很有希望。
试一试:)
在这里,您可以使用谷歌TTS,如下所示:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | 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(); } |
此外,谷歌的TTS也有类似于"?"的t护rkish字符的bug。,"?"所以您应该用Unicode转换它们:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 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,并要求用户安装…
不是:为了让TTS工作,你应该有真正的安卓设备。
我解决了这个问题,
定义该变量:
final Locale locale = new Locale("tr","TR");
在OnCreate方法中:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 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);
它会说"巴?局域网?"或"