I'm working on Text to Speech Application. I want to read a string in hindi like "हालाँकि सूर के जीवन के बारे में कई जनश्रुतियाँ प्रचलित हैं, पर इन में कितनी सच्चाई है यह कहना कठिन है" to speech here is my code but it's not working please help me how to set up hindi language please help me ?
public class MainActivity extends AppCompatActivity {
String string;
private int MY_DATA_CHECK_CODE = 0;
private TextToSpeech myTTS;
TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
string="हालाँकि सूर के जीवन के बारे में कई जनश्रुतियाँ प्रचलित हैं, पर इन में कितनी सच्चाई है यह कहना कठिन है";
StartSpeak(string);
}
private void StartSpeak(final String data) {
myTTS=new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() {
@Override
public void onInit(int initStatus) {
if (initStatus == TextToSpeech.SUCCESS) {
myTTS.setLanguage(new Locale("hin", "IND", "variant"));
// start speak
speakWords(data);
}
else if (initStatus == TextToSpeech.ERROR) {
Toast.makeText(getApplicationContext(), "Sorry! Text To Speech failed...", Toast.LENGTH_LONG).show();
}
}
});
}
private void speakWords(String speech) {
myTTS.speak(speech, TextToSpeech.QUEUE_FLUSH, null);
}
}