当前位置: 首页>>代码示例>>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;未经允许,请勿转载。