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

Saving and loading objects with arraylist properties of other custom objects (Android)
Ionic2 datetime start from min date
Multiple android api calls using RxJava
Audio (Record - Playback) Android Unusual Echo
publishing an android library on Bitbucket as a maven artifact issues
Android ble auto disconnect
delete sent sms using Receiver's Number instead of Sender's number
Material divider after category preference
Simple select statement of SQLite takes 15 sec to fetch 17 records
Load symbols from precompiled shared library
Firebase messaging without server XMPP server - Proposal
Displaying Allow app to access device's location
How to update Android Things-Apps?
FCM and Azure notification hub register
Converting Bitmap into base64 string and saving in Shared Preference
layout change when run on other mobile

Categories

HOME
kentico
devise
google-cloud-functions
carousel
telegram-bot
discrete-mathematics
computer-science
text-mining
activecollab
ycsb
jxl
tput
radgridview
3nf
mongodb-csharp
android-7.0-nougat
template-engine
symfony-console
replication
gulp-watch
named-entity-recognition
string-concatenation
imageresizer
pchart
jquery-callback
gmock
fable-f#
boost-asio
xbox
playstation-portable
rselenium
keras-layer
browser-extension
recurrent-neural-network
c9.io
hackintosh
azure-arm
magento-1.9.3
subclipse
outputcache
tcc
oim
openresty
hammer.js
dtsearch
launchctl
bluez
zenhub
qtranslate
static-cast
truezip
rackspace-cloud
trigger.io
google-photos
reachability
materialized-path-pattern
usart
docpad
angular2-testing
pacemaker
dotnetnuke-7
i386
cifilter
appscale
html-to-pdf
nullable
nio2
cycle2
mobiledoc-kit
user-management
character-replacement
google-books
ons-api
text-search
visual-sourcesafe-2005
viola-jones
uncompress
alloy-ui
osc
openbabel
primitive-types
cbind
trdion2011
rcaller
terminate
menubar
drupal-nodes
syndicationfeed
artemis
gtm-oauth2
c++builder-xe5
kogrid
redis-py
veracity
garbage
objectquery
window-decoration
jsr286
jquery-address
luabind
expression-blend-4
webdev.webserver
tmx
diagrams
object-database
aspmenu
silverlight-oob
feasibility
cldc

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