चेक बाहर Voice Reorganization in Android
आप नीचे के रूप में इसे लागू कर सकते हैं:
बटन जो आवाज का आशय बताएं फायरिंग के लिए जिम्मेदार है की क्लिक करें घटना पर नीचे दिए गए कोड लिखें।
/**
* Instruct the app to listen for user speech input
*/
private void listenToSpeech() {
//start the speech recognition intent passing required data
Intent listenIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
//indicate package
listenIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, getClass().getPackage().getName());
//message to display while listening
listenIntent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Say a word!");
//set speech model
listenIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
//specify number of results to retrieve
listenIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 10);
//start listening
startActivityForResult(listenIntent, VR_REQUEST);
}
जब इरादा वापस कॉल करता है, तो हम लिखित आवाज प्रदर्शित करते हैं।
/**
* onActivityResults handles:
* - retrieving results of speech recognition listening
* - retrieving result of TTS data check
*/
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//check speech recognition result
if (requestCode == VR_REQUEST && resultCode == RESULT_OK)
{
//store the returned word list as an ArrayList
ArrayList<String> suggestedWords = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
//set the retrieved list to display in the ListView using an ArrayAdapter
wordList.setAdapter(new ArrayAdapter<String> (this, R.layout.word, suggestedWords));
//to open the result in browser
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse("https://www.google.co.in/?gws_rd=cr#q="+suggestedWords));
startActivity(intent);
}
//tss code here
//call superclass method
super.onActivityResult(requestCode, resultCode, data);
}
आपके सुझाव के लिए धन्यवाद GrIsHu। इस तर्क के अनुसार मैं देख सकता हूं कि मैं ब्राउज़र में परिणाम प्राप्त कर पाऊंगा, लेकिन क्या आप कृपया सबसे सटीक परिणाम के लिए टीटीएस का उपयोग कैसे करें। उदाहरण के लिए यदि मैं पूछता हूं कि एफिल टावर कितना समय है, तो मुझे ब्राउजर में परिणाम मिल जाएगा, लेकिन मैं परिणाम का चयन कैसे कर सकता हूं जिस पर मैं आवाज प्रतिक्रिया के लिए टीटीएस का उपयोग करता हूं, ताकि परिणाम श्रव्य हो सके। – Shashi
क्या कहने की कोशिश कर रहे हैं कि मैं आपको नहीं मिल रहा हूं? – GrIsHu
जिस तरह से आप एंड्रॉइड डिवाइस पर Google सर्च वॉयस आइकन पर क्लिक करते हैं और किसी भी सवाल पूछते हैं, ज्यादातर बार यह स्क्रीन पर परिणाम प्रदर्शित करता है और ऑडियो के माध्यम से जवाब (भाषण में पाठ का उपयोग करके) बताता है। मैं जानना चाहता हूं कि यह कैसे करना है, मैं मूल रूप से दृश्य परिणामों में रूचि नहीं रखता हूं, बल्कि मुझे Google नाओ में उसी तरह से डिवाइस द्वारा बोली जाने वाले परिणामों की आवश्यकता होती है। अगर मुझे अभी भी पर्याप्त स्पष्ट नहीं है तो मुझे बताएं। – Shashi