December 18th, 2011, 08:18 PM
|
#1 (permalink)
|
|
New Member
Join Date: Dec 2011
Posts: 2
Device(s):
Thanks: 0
Thanked 0 Times in 0 Posts
|
Need loop code or ?
I have problem with voice recognition code, works first part but then uses 1st 'results' in the google search method... ugh..
code:
if (results.contains("play")){
Handler handler4 = new Handler();
handler4.postDelayed(new Runnable() {
public void run() {
mTts.speak("Play What?", TextToSpeech.QUEUE_FLUSH, null);
}
}, 1000);
Handler handler5 = new Handler();
handler5.postDelayed(new Runnable() {
public void run() {
Intent g = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
g.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
g.putExtra(RecognizerIntent.EXTRA_PROMPT, "Speak UP!");
g.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 1);
final ArrayList<String> results1 = data.getStringArrayListExtra(RecognizerIntent.EXTR A_RESULTS);
startActivityForResult(g, check);
Handler handler4 = new Handler();
handler4.postDelayed(new Runnable() {
public void run() {
Intent sgoogle = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.com/search?q=%22"+results1+"%22"));
startActivityForResult(sgoogle, check);
}
}, 12000);
}
}, 5000);
It is suppose to react to word 'play' which it does, then TTS ask "Play what?", which it does.. and then open recognizer, which it does.. then take results to google search, which is where its broken.. because it uses the 1st results of 'play' ..
Thank you in advance.
Flinx
|
|
|