Is there any free TTS (text-to-speech) service for Android in Turkish? I've not found anything useful in google.
I didnt try it yet on android, but I recently discovered this one: http://www.ispeech.org
The speech quality looks promising on the web app.
Give it a shot :)
Here you can use Google TTS as below:
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();
}
Moreover, Google TTS have bug with türkish character like "ö", "ğ" so that you should convert them with 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;
}
Some android device have pico TTS only, so that is why you check Google TTS, and ask user to install...
Not:In order tts to work,You should have real android device
I fixed this problem in my case,
define that variable:
final Locale locale = new Locale("tr", "TR");
in onCreate method:
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);
it will say "bağlanıyor"
just use Locale.getDefault()
tts.setLanguage(Locale.getDefault())
Related
I am developing TextToSpeech in Android. I use the following code and it work fine.
public void EnableTextToSpeech(){
//TextToSpeech
text_to_speech = new TextToSpeech(this, new TextToSpeech.OnInitListener() {
#Override
public void onInit(int status) {
if(status == TextToSpeech.SUCCESS){
Log.d(TAG,"TextToSpeech init SUCCESS");
int result = text_to_speech.setLanguage(Locale.US);
text_to_speech.setPitch(1);
text_to_speech.setSpeechRate(1);
if(result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED){
Log.d(TAG,"TextToSpeech NOT SUPPORT");
}else {
Log.d(TAG,"TextToSpeech Enable");
String welcome = "Welcome";
text_to_speech.speak(welcome , TextToSpeech.QUEUE_FLUSH,null,"TEST");
}
}else {
Log.d(TAG,"TextToSpeech init FAIL");
}
}
});
}
But I want it to speak the multiple language like Chines and English in one sentence.
Can I set different language like the following code?
text_to_speech.setLanguage(Locale.CHINESE);
text_to_speech.setLanguage(Locale.US);
How to set and speak multiple language in a sentence for TextToSpeech in Android ?
I am getting an error with the conversion of the text to speech in android studio. I have initialised the code but it still returns no voice outputs. The code is as follows.
else if((match.contains("yes") || match.contains("yeah")) && defsele) {
//Toast toast = Toast.makeText(getApplicationContext(), "Default selection is done and program is starting", Toast.LENGTH_SHORT);
//toast.show();
defsele=false;
switch (progno) {
case 1:
//Toast toast1 = Toast.makeText(getApplicationContext(),"The default settings for cotton cycle is done",Toast.LENGTH_SHORT);
//toast1.show();
String cotton = "The cotton program is starting with the default values";
tts.speak(cotton, TextToSpeech.QUEUE_FLUSH, null);
soak=true;
soakdef();
break;
The tts.speak gets deprecated and does not function. How can I make this work? The initialisation code is as follows:
tts = new TextToSpeech(this,this);
#Override
public void onInit(int status) {
Log.d("Speech", "OnInit - Status ["+status+"]");
if(status == TextToSpeech.SUCCESS){
Log.d("Speech","Success");
tts.setLanguage(Locale.ENGLISH);
TextToSpeech textToSpeech = new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() {
#Override
public void onInit(int status) {
//your text
String textToSpeechStr = "Hello";
//status is success / 0
if (status == TextToSpeech.SUCCESS) {
//speech starts
textToSpeech.speak(textToSpeechStr, TextToSpeech.QUEUE_FLUSH, null);
}
}
});
I am trying to add text-to-speech feature to my app, and it is working fine until I updated TTS from Google Play store.
There wasn't any delay to initialize the TTS in onCreate Method.
After the update, it would take 3-5 seconds for this TTS to finish initializing.
Basically, the text-to-speech is not ready until 3-5 seconds later.
Can someone please tell me what I've done wrong?
private HashMap<String, String> TTS_ID = new HashMap<String, String>();
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
.....
.....
TextToSpeech_Initialize();
}
public void TextToSpeech_Initialize() {
TTS_ID.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "UniqueID");
speech = new TextToSpeech(MainActivity.this, new TextToSpeech.OnInitListener() {
#Override
public void onInit(int status) {
if(status == TextToSpeech.SUCCESS) {
speech.setSpeechRate(SpeechRateValue);
speech.speak(IntroSpeech, TextToSpeech.QUEUE_FLUSH, TTS_ID);
}
}
});
}
Thank you very much
Confirmed! This is an issue with Google text to speech engine, if you try any other tts the delay disappears, eg Pico tts.
I have stumbled across this problem before but now I have found a proper solution..
You can initialize TextToSpeach in onCreate() like this:
TextToSpeach textToSpeech = new TextToSpeech(this, this);
but first you need to implement TextToSpeech.OnInitListener, and then you need to override the onInit() method:
#Override
public void onInit(int status) {
if (status == TextToSpeech.SUCCESS) {
int result = tts.setLanguage(Locale.US);
if (result == TextToSpeech.LANG_MISSING_DATA
|| result == TextToSpeech.LANG_NOT_SUPPORTED) {
Toast.makeText(getApplicationContext(), "Language not supported", Toast.LENGTH_SHORT).show();
} else {
button.setEnabled(true);
}
} else {
Toast.makeText(getApplicationContext(), "Init failed", Toast.LENGTH_SHORT).show();
}
}
I also noticed that if you didn't set the language in onInit() there is gonna be a delay!!
And now you can write the method that says the text:
private void speakOut(final String detectedText){
if(textToSpeech !=null){
textToSpeech.stop(); //stop and say the new word
textToSpeech.speak(detectedText ,TextToSpeech.QUEUE_FLUSH, null, null);
}
}
I am new to turn based game development and trying to develop a turn based game. I am using default UI for selecting players
Intent intent = Games.TurnBasedMultiplayer.getSelectOpponentsIntent(getApiClient(), 1, 1, true);
startActivityForResult(intent, RC_SELECT_PLAYERS);
When I select player sand say Play, other player is supposed to get notification. But that player is not receiving invitation / notification.
#Override
public void onSignInSucceeded() {
updateLayouts();
Games.Invitations.registerInvitationListener(getApiClient(), this);
// developer document says that above line is not required
// include or exclude for me it is not making any difference
}
#Override
public void onInvitationReceived(Invitation invitation) {
Toast.makeText(
this,
"An invitation has arrived from "
+ invitation.getInviter().getDisplayName(), Toast.LENGTH_LONG)
.show();
Log.d(TAG, "Invitation arrived from " + invitation.getInviter().getDisplayName());
}
Here is my onActivtityResult
#Override
public void onActivityResult(int request, int response, Intent data) {
super.onActivityResult(request, response, data);
if (request == RC_LOOK_AT_MATCHES) {
// Returning from the 'Select Match' dialog
if (response != Activity.RESULT_OK) {
// user canceled
return;
}
TurnBasedMatch match = data
.getParcelableExtra(com.google.android.gms.games.multiplayer.Multiplayer.EXTRA_TURN_BASED_MATCH);
if (match != null) {
updateMatch(match);
}
Log.d(TAG, "Match = " + match);
}
else if (request == RC_SELECT_PLAYERS) {
if (response != Activity.RESULT_OK) {
// user canceled
return;
}
// get the invitee list
final ArrayList<String> invitees =
data.getStringArrayListExtra(Games.EXTRA_PLAYER_IDS);
Log.d(TAG, "Invitees count = " + invitees.size());
for(int i=0; i<invitees.size(); i++){
Log.d(TAG, invitees.get(i));
}
// get auto-match criteria
Bundle autoMatchCriteria = null;
int minAutoMatchPlayers = data.getIntExtra(
Multiplayer.EXTRA_MIN_AUTOMATCH_PLAYERS, 0);
int maxAutoMatchPlayers
= data.getIntExtra(
Multiplayer.EXTRA_MAX_AUTOMATCH_PLAYERS, 0);
if (minAutoMatchPlayers > 0) {
autoMatchCriteria
= RoomConfig.createAutoMatchCriteria(
minAutoMatchPlayers, maxAutoMatchPlayers, 0);
Log.d(TAG, "minAutoMatchPlayers > 0");
} else {
autoMatchCriteria = null;
Log.d(TAG, "minAutoMatchPlayers <= 0");
}
TurnBasedMatchConfig tbmc = TurnBasedMatchConfig.builder()
.addInvitedPlayers(invitees)
.setAutoMatchCriteria(autoMatchCriteria).build();
// kick the match off
Games.TurnBasedMultiplayer
.createMatch(getApiClient(), tbmc)
.setResultCallback(new ResultCallback<TurnBasedMultiplayer.InitiateMatchResult>() {
#Override
public void onResult(TurnBasedMultiplayer.InitiateMatchResult result) {
processResult(result);
}
});
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
showSpinner();
}
}
Can Anyone tell me where I am going wrong?
The notification happens after the first player (who created the match) takes his turn by calling Games.TurnBasedMultiplayer.takeTurn() and not right away after the match is created.
Can also try this. If there is no invitations (even when your app is closed), the account-lvl restrictions can block them.
I have gone through almost all the links related to this topic but haven't found any suitable answer. I am trying to build a basic text to speech application. It works perfectly fine on the emulator. But when i run it on my phone, it shows language not supported.
I guess this has something to do with the locale. The default locale set in my phone is en_US
My code is as follows:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tts = new TextToSpeech(this, this);
btnSpeak = (Button) findViewById(R.id.btnSpeak);
txtText = (EditText) findViewById(R.id.txtText);
btnSpeak.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
// Method yet to be defined
speakOut();
}
});
}
public void onInit(int status) {
// TODO Auto-generated method stub
// TTS is successfully initialized
if (status == TextToSpeech.SUCCESS) {
// Setting speech language
// System.out.println(Locale.getAvailableLocales());
int result = tts.setLanguage(Locale.ENGLISH);
// int result = tts.setLanguage(Locale.getDefault());
// If your device doesn't support language you set above
if (result == TextToSpeech.LANG_MISSING_DATA
|| result == TextToSpeech.LANG_NOT_SUPPORTED) {
// Cook simple toast message with message
Toast.makeText(this, "Language not supported",
Toast.LENGTH_LONG).show();
Log.e("TTS", "Language is not supported");
} else {
btnSpeak.setEnabled(true);
}
// TTS is not initialized properly
} else {
Toast.makeText(this, "TTS Initilization Failed", Toast.LENGTH_LONG)
.show();
Log.e("TTS", "Initilization Failed");
}
}
private void speakOut() {
// Get the text typed
String text = txtText.getText().toString();
// If no text is typed, tts will read out 'You haven't typed text'
// else it reads out the text you typed
if (text.length() == 0) {
tts.speak("You haven't typed text", TextToSpeech.QUEUE_FLUSH, null);
} else {
tts.speak(text, TextToSpeech.QUEUE_FLUSH, null);
}
}
public void onDestroy() {
// Don't forget to shutdown!
if (tts != null) {
tts.stop();
tts.shutdown();
}
super.onDestroy();
}
even if i use int result = tts.setLanguage(Locale.getDefault()); instead of Locale.ENGLISH, it shows the same language not supported message
LOGCAT ERROR:
02-26 16:24:57.492: I/TextToSpeech.java(23356): initTts() successfully bound to service
02-26 16:24:58.015: E/TTS(23356): Language is not supported
I am running this on my phone- Samsung Galaxy-Y (GT-S5360) with Android version 2.3.6
found a solution myself. the problem was that the locales available on the android default tts engine did not match those on my phone.
i installed another tts engine and it works perfectly fine with it.