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

How to hide popping up Google Play's unlocked achievement programatically?
having trouble with my xml file. Error parsing xml :invalid token [closed]
Android: Is there any other way to get the SIM number from the android device other than getLine1number()?
android : Not able to show mylocation on google maps v2
Android Camera getSupportedPreviewSizes() error
Prevent Downloading Existing File Again And Again
Android - Google Play - Upload APK
Error while consuming soap web service with android
Android preferences - How to create a ListPreference NOT as a dialog
Send intent to open data URI (RFC 2397)?
Remotely start Android phone
PopupWindow + full screen => show notification-bar?
Delphi XE6 android with estimote beacon convertion
3d simulation: setting up frustum, viewport, camera, etc
OSMDroid, Android - evoke pinch zoom programmaticaly
In android when i try to run my project it says 'No resource found that matches the given name 'Theme.AppCompat.Light'? [duplicate]

Categories

HOME
go
jpa
delphi-7
c++11
css3
mysql-workbench
replace
tivoli
echo
iis-6
angularfire2
opengl-3
syntaxnet
google-chrome-app
endeca
mod-security
mxgraph
code-generation
bitnami
coin3d
user-experience
strongname
google-cloud-print
corpus
ms-access-web-app
outliers
fractions
soot
carrierwave
testcomplete
autodesk-designautomation
biztalk-rule-engine
python-pptx
latitude-longitude
sim-toolkit
p4merge
urlsession
doc
facebook-social-plugins
dynamic-linq
ovf
linter
gitlist
cnc
globalize
mschart
rserve
payara-micro
wpas
arules
er-diagram
check-mk
ampps
reachability
chromium-os
jboss-tools
embedding
angular-ui-typeahead
spreadjs
createprocess
contentcontrol
design-principles
phpgrid
xenomai
computer-architecture
binomial-theorem
pax-exam
cgi-bin
ember-cli-rails
mod-proxy
sha512
airbrake
mmwormhole
android-cookiemanager
jbake
sonarqube-5.0
entry-point
tweenlite
nsmenu
insight.database
with-statement
rcaller
paste
file-not-found
drupal-nodes
mt4j
sphinxql
rolify
mongohq
bjyauthorize
booksleeve
mapping-by-code
jquery-address
htdocs
landscape-portrait
update-statement
listactivity
presentation-layer
vs-android
globals
ajax-polling
build-environment
google-wave
xslcompiledtransform
pnrp

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