text to speech - Removing a part of a string in android -


i have app has texttospeech feature read lots of words in edit text,here code:

package com.example.texttospch; import android.app.activity; import android.os.bundle; import android.speech.tts.texttospeech; import android.view.view; import android.widget.button; import android.widget.edittext; import android.widget.toast;  import java.util.locale;  public class myactivity extends activity implements texttospeech.oninitlistener {     texttospeech tts;     edittext edt;     button btn;     @override  public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.main);        init();     btn.setonclicklistener(new view.onclicklistener() {         @override          public void onclick(view v) {              speakout();         }      }); }  private void init() {     edt= (edittext) findviewbyid(r.id.edt);     btn= (button) findviewbyid(r.id.btn);     tts=new texttospeech(this,this); }  @override public void oninit(int status) {     if (status==texttospeech.success) {         tts.setlanguage(locale.us);     }     if (status==texttospeech.lang_missing_data){         toast.maketext(getapplicationcontext(),"text speech not supported",toast.length_long).show();     } }  @override protected void ondestroy() {     super.ondestroy();     tts.shutdown(); }  private void speakout() {  string text=edt.gettext().tostring();     if (null==text||"".equals(text)){         text="please give input";     }     tts.speak(text,texttospeech.queue_flush,null); } } 

i have words 1 : ability (n.) ,or 1 : dizzy (adj.), don't want tts read kind of word. there way that? :

if(text.contains("(n.)"){     string newtext = text-"(n.)" } 

and tell tts read newtext?

string stringtoremove = "(n.)"; if(text.contains(stringtoremove){     string  newtext = text.replaceall(stringtoremove, ""); } 

hope works.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -