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

android countdowntimer can not stop
I can not align Layout
Qt on Android - does the C++ code run in the Dalvik virtual machine
Send an object to another activity using parcelable
Send image from one activity to another activity imageview [closed]
Using custom title bar in android studio
how to Select multiple radiobuttons in listview and arranging in arraylist using their positions
How to call fragment from activity without using fragmentactivity?
Gimbal Proximity sdk throws error only on Lollipop devices
Intent without action cannot pass intent filter test. Why?
android animation move view to another view
Change image position in runtime
how to attach image in email in android
Android Map disable 3D mode
How to send SMS using Twilio in my android application?
Text-shadow rendering on Android 4.4.2 bug

Categories

HOME
gridview
jpa
deep-learning
codenvy
redux-form
pda
camera
nested-if
angularfire2
extjs4.2
resultset
emoji
xcodebuild
tput
symmetricds
event-sourcing
alpacajs
dynamic-sql
fileserver
google-content-api
wolframalpha
smartclient
jmp
symbols
inno-download-plugin
angular-routing
imageresizer
exit
zxing
interpreter
ckfinder
custom-post-type
jackson-modules
apktool
tpm
dst
simplecv
android-maps-extensions
installshield-le
getpixel
fiware-cygnus
sim-toolkit
apic
zoomify
bc
urlsession
apache-stanbol
numberpicker
microsoft-metro
http-request
signal-strength
jide
rserve
avx
reachability
vcloud-director-rest-api
materialized-path-pattern
spring-cloud-feign
resourcemanager
ng-grid
gogs
simevents
cda
sklearn-pandas
dynamics-nav-2016
gocql
django-urls
cwrsync
user-permissions
theos
execve
with-statement
parallel-testing
grails-plugin-rabbitmq
radiant
scringo
gpars
wimax
robotlegs
panda3d
objectquery
floating-point-exceptions
cuteeditor
cdonts
load-time
linfu-dynamicproxy
pnrp
netbeans6.1

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