android


text to speech not working as initialization is not over


I am followiing this question to make tts to work
Android TTS doesn't speak
But in the answer he gave say(gameover,true),say(line,false),say(definition_string,false)
please could anyone help me by telling what are those terms.
This is my code
public class SecondActivity extends AppCompatActivity implements OnInitListener {
TextToSpeech t1;
// private final int REQ_CODE_SPEECH_INPUT = 100;
String emailid;
#Override
protected void onCreate(Bundle savedInstanceState) {
emailid="Hi,say your email id";
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
t1=new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() {
#Override
public void onInit(int status) {
if(status != TextToSpeech.ERROR) {
t1.setLanguage(Locale.US);
}
}
});
Toast.makeText(getApplicationContext(), emailid,Toast.LENGTH_SHORT).show();
t1.speak(emailid, TextToSpeech.QUEUE_FLUSH, null);
}
public void onPause(){
if(t1 !=null){
t1.stop();
t1.shutdown();
}
super.onPause();
}
}
Try this and see if it works:
public class TextToSpeechController implements TextToSpeech.OnInitListener{
private Context mContext;
private TextToSpeech tts;
public TextToSpeechController(Context context) {
mContext = context;
tts = new TextToSpeech(context, this);
}
#Override
public void onInit(int status) {
Log.e("INIT TTS", "INIT");
if (status == TextToSpeech.SUCCESS) {
int result = tts.setLanguage(Locale.ENGLISH);
if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) {
Toast.makeText(mContext, "This Language is not supported", Toast.LENGTH_LONG).show();
}
else {
Toast.makeText(mContext, "Ready to Speak", Toast.LENGTH_LONG).show();
speakTheText("Welcome to the App");
}
}
else {
Toast.makeText(mContext, "Can Not Speak", Toast.LENGTH_LONG).show();
}
}
public void stopTTS(){
tts.stop();
tts.shutdown();
}
public void speakTheText(String str){
tts.speak(str, TextToSpeech.QUEUE_FLUSH, null);
}

Related Links

Why do SearchView and android.support.v7.widget.SearchView not focus anymore
RxJava: return a cached value synchronously/immediately
How to check for string changes after a user presses a Button?
android - groovy script error in custom live template
How to zoom in an ImageView in Android
How to load string.xml for indian languages in android?
Classic asp or phonegap
Android WhisperSystems/libsignal-service
android retrofit await method to finish outside of response
Unable to restore array to array adapter when addTextChangedListener is used
Detect if first auth via Facebook/Google
Install error when trying to update android application programmatically [duplicate]
Android the navigation toolbar icon and logo can not align
Reverse image on Nexus 5x in portrait
Android Studio 2.3, cannot build gradle. Error 304 [duplicate]
Android - How to allow/enable “Floating notifications” setting as default for App using code

Categories

HOME
amp-html
depth
powerpoint
mstest
carousel
mapbox
jtextpane
joomla3.0
qpython
plist
project-intu
onedrive-api
google-picker
git-extensions
imessage
mapstruct
oledb
parcelable
joptionpane
monit
comparator
ckfinder
game-theory
data.stackexchange.com
maze
ms-access-2003
openmdao
comparable
mql
mobx
login-script
gojs
navigator
android-augmented-reality
trigonometry
escpos
plan-9
puredata
vaadin-elements
double-click
mesosphere
chai-as-promised
twilio-click-to-call
activeperl
er-diagram
check-mk
trigger.io
swingworker
cronexpression
slackware
centrifuge
google-cloud-console
x-tag
mapinfo
scaffolding
shopping
deep
aurora
lz77
libav
aspen
terracotta
jdk1.7
linked-tables
mirror
aspectj-maven-plugin
xmltype
qtwebengine
beatsmusic
spy++
live555
paste
clickbank
gwt-openlayers
embedded-fonts
android-loadermanager
onmousemove
wcf-configuration
mapping-by-code
convention
role
filemerge
multiplatform
mtu
uideviceorientation
interprocess
openfaces
django-piston
fdf

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App