當前位置: 首頁>>代碼示例>>Java>>正文


Java RecognizerIntent.ACTION_RECOGNIZE_SPEECH屬性代碼示例

本文整理匯總了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();

}
 
開發者ID:panda919,項目名稱:AndroidVoiceRecognitionPanda,代碼行數:20,代碼來源:SpeechRecognizerManager.java

示例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();
    }
 
開發者ID:shashi2459,項目名稱:notify-me,代碼行數:26,代碼來源:MainActivity.java

示例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);
}
 
開發者ID:inteliedoit,項目名稱:thesis-project,代碼行數:19,代碼來源:ExamInputAdapter.java

示例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();
    }
}
 
開發者ID:aliyun,項目名稱:aliyun-cloudphotos-android-demo,代碼行數:16,代碼來源:MainActivity.java

示例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();
    }
}
 
開發者ID:Captwalloper,項目名稱:NUI_Project,代碼行數:18,代碼來源:VoiceActivity.java

示例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));
        }
    }
}
 
開發者ID:Mun0n,項目名稱:MADBike,代碼行數:18,代碼來源:SearchActivity.java

示例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();
    }
}
 
開發者ID:Cesarsk,項目名稱:Say_it,代碼行數:18,代碼來源:SearchActivity.java

示例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;
    }
}
 
開發者ID:pabloccid,項目名稱:SmartLocker,代碼行數:24,代碼來源:MainActivity.java

示例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;
        }
    }
}
 
開發者ID:pabloccid,項目名稱:SmartLocker,代碼行數:17,代碼來源:AdminActivity.java

示例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);
}
 
開發者ID:shashi2459,項目名稱:notify-me,代碼行數:21,代碼來源:HeadPhoneListener.java

示例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();
    }
}
 
開發者ID:santiihoyos,項目名稱:LazarilloApp,代碼行數:21,代碼來源:FragmentoIr.java

示例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();
}
 
開發者ID:pribeiro89,項目名稱:LeRudePal,代碼行數:17,代碼來源:SpeechInputActivity.java

示例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);
    }
  }
}
 
開發者ID:SchibstedSpain,項目名稱:Leku,代碼行數:16,代碼來源:LocationPickerActivity.java

示例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);
    }
 
開發者ID:gpenverne,項目名稱:api-recipe,代碼行數:23,代碼來源:SpeechRecognition.java

示例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;
        }
    }
}
 
開發者ID:JoaoCnh,項目名稱:react-native-android-voice,代碼行數:25,代碼來源:VoiceModule.java


注:本文中的android.speech.RecognizerIntent.ACTION_RECOGNIZE_SPEECH屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。