本文整理汇总了Java中android.speech.RecognizerIntent.ACTION_RECOGNIZE_SPEECH属性的典型用法代码示例。如果您正苦于以下问题:Java RecognizerIntent.ACTION_RECOGNIZE_SPEECH属性的具体用法?Java RecognizerIntent.ACTION_RECOGNIZE_SPEECH怎么用?Java RecognizerIntent.ACTION_RECOGNIZE_SPEECH使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.speech.RecognizerIntent
的用法示例。
在下文中一共展示了RecognizerIntent.ACTION_RECOGNIZE_SPEECH属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SpeechRecognizerManager
public SpeechRecognizerManager(Context context,onResultsReady listener)
{
try{
mListener=listener;
}
catch(ClassCastException e)
{
Log.e(TAG,e.toString());
}
mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(context);
mSpeechRecognizer.setRecognitionListener(new SpeechRecognitionListener());
mSpeechRecognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,
context.getPackageName());
startListening();
}
示例2: onCreate
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mHeadPhoneListener = new HeadPhoneListener();
mSpeechStateView = (TextView) findViewById(R.id.stateTextView);
updateUI();
/*
* Init Speech Recognizer
*/
final SpeechRecognizer recognizer = SpeechRecognizer
.createSpeechRecognizer(MainActivity.this);
final Intent recognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
recognizerIntent.putExtra(
RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, getPackageName());
// recognizer.setRecognitionListener(this);
recognizer.setRecognitionListener(new SpeechListener(mHandler));
// onClick(recognizer, recognizerIntent);
permissionsCheck();
registerForIntent();
}
示例3: StudentAdapterViewHolder
StudentAdapterViewHolder(View itemView) {
super(itemView);
studentImage = (ImageView) itemView.findViewById(R.id.f_data_student_profile);
studentDetail = (TextView) itemView.findViewById(R.id.input_cardview_name);
editText = (EditText) itemView.findViewById(R.id.input_cardview_score);
layout = (LinearLayout) itemView.findViewById(R.id.input_cardview_layout);
txInit = (TextView) itemView.findViewById(R.id.input_cardview_init);
btnMic = (ToggleButton) itemView.findViewById(R.id.input_cardview_mic);
progressBar = (ProgressBar) itemView.findViewById(R.id.progressBarney);
btnMic.setOnCheckedChangeListener(this);
speech = SpeechRecognizer.createSpeechRecognizer(context);
speech.setRecognitionListener(this);
recognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, "en");
recognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, context.getPackageName());
recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 3);
}
示例4: startVoiceRecognition
void startVoiceRecognition() {
try{
//通过Intent传递语音识别的模式,开启语音
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
//语言模式和自由模式的语音识别
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
//提示语音开始
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "开始语音");
//开始语音识别
startActivityForResult(intent, VOICE_SEARCH_CODE);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
Toast.makeText(getApplicationContext(), "找不到语音设备", 1).show();
}
}
示例5: promptSpeechInput
/**
* Showing google speech input dialog
* */
private void promptSpeechInput() {
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault());
intent.putExtra(RecognizerIntent.EXTRA_PROMPT,
getString(R.string.speech_prompt));
try {
startActivityForResult(intent, REQ_CODE_SPEECH_INPUT);
} catch (ActivityNotFoundException a) {
Toast.makeText(getApplicationContext(),
getString(R.string.speech_not_supported),
Toast.LENGTH_SHORT).show();
}
}
示例6: onAutoPressed
@OnClick(R.id.autoButton)
public void onAutoPressed() {
if (clear) {
autoCompleteTextView.setText("");
} else {
Intent intent = new Intent(
RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, Locale.getDefault().getDisplayLanguage());
try {
startActivityForResult(intent, RESULT_SPEECH);
autoCompleteTextView.setText("");
} catch (ActivityNotFoundException a) {
notificationManager.showMessage(getString(R.string.error_no_mic));
}
}
}
示例7: promptSpeechInput
/**
* Showing google speech input dialog
*/
private void promptSpeechInput() {
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault());
intent.putExtra(RecognizerIntent.EXTRA_PROMPT,
getString(R.string.speech_prompt));
try {
startActivityForResult(intent, REQ_CODE_SPEECH_INPUT);
} catch (ActivityNotFoundException a) {
Toast.makeText(getApplicationContext(),
getString(R.string.speech_not_supported),
Toast.LENGTH_SHORT).show();
}
}
示例8: desbloquear
/**
* Funcionalidad que inicializa la API de reonocimiento de voz para detectar la palabra clave
* que sirve para desbloquear la caja (cuando se encuentra bloqueada por intentos fallidos).
*
* Si flag_voice es false significa que el servicio no está activo, por ende se activa y
* comienza a escuchar.
* Si flag_voice es true significa que estaba activo, entonces para el servicio, deja de escuchar.
*
*/
public void desbloquear(View view) {
if (flag_voice == false) {
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, getApplication().getPackageName());
intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 5);
sr.startListening(intent);
Log.i("VOICE", "START");
flag_voice = true;
} else {
sr.stopListening();
flag_voice = false;
}
}
示例9: onClick
public void onClick(View v) {
if (v.getId() == R.id.buttonListen) {
if (flag_voice == false) {
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, getApplication().getPackageName());
intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 5);
sr.startListening(intent);
Log.i("VOICE", "START");
flag_voice = true;
} else {
sr.stopListening();
flag_voice = false;
}
}
}
示例10: initSpeechRecognizer
private void initSpeechRecognizer() {
Log.e(TAG, "initSpeechRecognizer: ");
Handler handler = getHandler();
mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(mContext);
final Intent recognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
recognizerIntent.putExtra(
RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,
mContext.getPackageName());
mSpeechRecognizer.setRecognitionListener(new SpeechListener(handler));
mSpeechRecognizer.startListening(recognizerIntent);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
mSpeechRecognizer.stopListening();
}
}, DELAY_MILLIS);
}
示例11: reconocerVoz
/**
* Lanza el intent para el reconocimiento de la voz por parte de la api de Google para ello.
* luego retorna el texto hacia atrás por el metodo onActivityResult.
*/
private void reconocerVoz() {
// Intent del Reconocimiento de Voz
Intent intentActionRecognizeSpeech = new Intent(
RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
// Configura el Lenguaje (Español-España)
intentActionRecognizeSpeech.putExtra(
RecognizerIntent.EXTRA_LANGUAGE_MODEL, "es-ES");
// Inicia la Actividad
try {
startActivityForResult(intentActionRecognizeSpeech, 1);
} catch (ActivityNotFoundException a) {
Toast.makeText(getActivity(), "¡Opps! Tú dispositivo no soporta Speech to Text, deberas instalar Google Voice", Toast.LENGTH_SHORT).show();
}
}
示例12: speechToText
private void speechToText(){
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, language); //Passar Lingua.
intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS,1);
sr.startListening(intent);
new CountDownTimer(2000, 1000)
{
public void onTick(long millisUntilFinished) {
}
public void onFinish() {
sr.stopListening();
}
}.start();
}
示例13: startVoiceRecognitionActivity
private void startVoiceRecognitionActivity() {
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, getString(R.string.leku_voice_search_promp));
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE,
getString(R.string.leku_voice_search_extra_language));
if (checkPlayServices()) {
try {
startActivityForResult(intent, REQUEST_PLACE_PICKER);
} catch (ActivityNotFoundException e) {
track(TrackEvents.startVoiceRecognitionActivityFailed);
}
}
}
示例14: startRecognition
private void startRecognition() {
final Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,"voice.recognition.test");
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE,lang);
intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS,5);
Handler loopHandler = new Handler(Looper.getMainLooper());
loopHandler.post(new Runnable() {
@Override
public void run() {
recognizer.startListening(intent);
}
});
PluginResult res = new PluginResult(PluginResult.Status.NO_RESULT);
res.setKeepCallback(true);
this.speechRecognizerCallbackContext.sendPluginResult(res);
}
示例15: startSpeech
@ReactMethod
public void startSpeech(String prompt, String locale, final Promise promise) {
Activity currentActivity = getCurrentActivity();
if (currentActivity == null) {
promise.reject(ErrorConstants.E_ACTIVITY_DOES_NOT_EXIST);
return;
}
mVoicepromise = promise;
final Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, getLocale(locale));
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, getPrompt(prompt));
if (intent.resolveActivity(this.reactContext.getPackageManager()) != null) {
try{
this.reactContext.startActivityForResult(intent, REQUEST_SPEECH_ACTIVITY, null);
}catch(Exception ex){
mVoicepromise.reject(ErrorConstants.E_FAILED_TO_SHOW_VOICE);
mVoicepromise = null;
}
}
}