当前位置: 首页>>代码示例>>Java>>正文


Java SpeechRecognizer.createSpeechRecognizer方法代码示例

本文整理汇总了Java中android.speech.SpeechRecognizer.createSpeechRecognizer方法的典型用法代码示例。如果您正苦于以下问题:Java SpeechRecognizer.createSpeechRecognizer方法的具体用法?Java SpeechRecognizer.createSpeechRecognizer怎么用?Java SpeechRecognizer.createSpeechRecognizer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.speech.SpeechRecognizer的用法示例。


在下文中一共展示了SpeechRecognizer.createSpeechRecognizer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: SpeechRecognizerManager

import android.speech.SpeechRecognizer; //导入方法依赖的package包/类
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,代码行数:21,代码来源:SpeechRecognizerManager.java

示例2: onCreate

import android.speech.SpeechRecognizer; //导入方法依赖的package包/类
@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,代码行数:27,代码来源:MainActivity.java

示例3: StudentAdapterViewHolder

import android.speech.SpeechRecognizer; //导入方法依赖的package包/类
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,代码行数:20,代码来源:ExamInputAdapter.java

示例4: onCreate

import android.speech.SpeechRecognizer; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_robot);
    //hide
    ActionBar actionBar = getActionBar();
    if (null != actionBar)
        actionBar.hide();

    mHandler = new responseHandler();
    mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(this, new
            ComponentName(
            this, VoiceRecognitionService.class));
    mSpeechRecognizer.setRecognitionListener(new
            CustomRecognitionListener());
    initVariables();
    initData();
    initView();
    iniListener();
    mSpeechSynthesizer = SpeakerUtils.getInstance(RobotActivity.this).initialTts();

}
 
开发者ID:AleGogogo,项目名称:MaoMaoRobot,代码行数:23,代码来源:RobotActivity.java

示例5: initSpeechRecognizer

import android.speech.SpeechRecognizer; //导入方法依赖的package包/类
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,代码行数:22,代码来源:HeadPhoneListener.java

示例6: createSpeechRecognizer

import android.speech.SpeechRecognizer; //导入方法依赖的package包/类
@ReactMethod
public void createSpeechRecognizer(final Promise promise) {
  if (reactContext == null)
    throw new IllegalArgumentException("ReactApplicationContext must be defined!");

  if (mSpeechRecognizer != null) {
    mSpeechRecognizer.destroy();
    mSpeechRecognizer = null;
  }

  if (SpeechRecognizer.isRecognitionAvailable(reactContext)) {
    mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(reactContext);
    mSpeechRecognizer.setRecognitionListener(new SpeechRecognitionListener(
        this.reactContext.getJSModule(RCTNativeAppEventEmitter.class)
    ));
    promise.resolve(null);
  } else{
    promise.reject("error", "SpeechRecognizer not available");
  }
}
 
开发者ID:marshmelloX,项目名称:react-native-stt,代码行数:21,代码来源:RNSpeechToText.java

示例7: createRecognizer

import android.speech.SpeechRecognizer; //导入方法依赖的package包/类
public static SpeechRecognizer createRecognizer(AppCompatActivity activity, SpeechActionListener resultHandler, String wakeUpPhrase) {
        speechRecognizer =
                SpeechRecognizer.createSpeechRecognizer(activity);
        loadingRecognizer = new ProgressDialog(activity, R.style.AppCompatAlertDialogStyle);
        loadingRecognizer.setIndeterminate(true);
        loadingRecognizer.setMessage("Starting up Voice Listener...");
        loadingRecognizer.show();
        speechRecognizer.setRecognitionListener(new SpeechListener(resultHandler));
        wakeUpPhraseText = wakeUpPhrase;
        textView = (TextView) activity.findViewById(R.id.spokenText);
        intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
        intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, activity.getPackageName());
        intent.putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS, true);
        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "fr-FR");
        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, "fr-FR");
        intent.putExtra(RecognizerIntent.EXTRA_ONLY_RETURN_LANGUAGE_PREFERENCE, "fr-FR");
        intent.putExtra(RecognizerIntent.EXTRA_PREFER_OFFLINE, true);
//        intent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_POSSIBLY_COMPLETE_SILENCE_LENGTH_MILLIS, 10000);
//        intent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_MINIMUM_LENGTH_MILLIS, 500);
//        intent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS, 2500);
//            intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 5);
        speechRecognizer.startListening(intent);
        return speechRecognizer;
    }
 
开发者ID:Palo-IT,项目名称:voice-IT,代码行数:26,代码来源:SpeechToTextAction.java

示例8: recordVoice

import android.speech.SpeechRecognizer; //导入方法依赖的package包/类
@OnClick(R.id.fab_record)
public void recordVoice(View view){

    //Set up
    mHearingText.setVisibility(View.VISIBLE);
    mHearingText.setAlpha(0f);

    //Recording
    recognizer = SpeechRecognizer.createSpeechRecognizer(getContext());
    recognizer.setRecognitionListener(this);

    Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, "it-IT");
    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "it-IT");
    intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS,5);
    recognizer.startListening(intent);

}
 
开发者ID:Marplex,项目名称:Schoolbook,代码行数:19,代码来源:Reminds.java

示例9: onCreate

import android.speech.SpeechRecognizer; //导入方法依赖的package包/类
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mHandler = new responseHandler();
        // mManager = DatabaseManager.getIntance(MainActivity.this);
        mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(this, new
                ComponentName(
                this, VoiceRecognitionService.class));
        mSpeechRecognizer.setRecognitionListener(new
                CustomRecognitionListener());
        initData();
        initView();
        iniListener();
//        loadData();

    }
 
开发者ID:AleGogogo,项目名称:MaoMaoRobot,代码行数:18,代码来源:MainActivity.java

示例10: onCreate

import android.speech.SpeechRecognizer; //导入方法依赖的package包/类
/**
     * Use this factory method to create a new instance of
     * this fragment using the provided parameters.
     *
     * @param param1 Parameter 1.
     * @param param2 Parameter 2.
     * @return A new instance of fragment VoiceInputFragment.
     */
    // TODO: Rename and change types and number of parameters
//    public static VoiceInputFragment newInstance(String param1, String param2) {
//        VoiceInputFragment fragment = new VoiceInputFragment();
//        Bundle args = new Bundle();
//        args.putString(ARG_PARAM1, param1);
//        args.putString(ARG_PARAM2, param2);
//        fragment.setArguments(args);
//        return fragment;
//    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(getContext(), new ComponentName(getContext(), VoiceRecognitionService.class));
        mSpeechRecognizer.setRecognitionListener(this);
    }
 
开发者ID:solrex,项目名称:WhatIsWhat,代码行数:25,代码来源:VoiceInputFragment.java

示例11: onStartCommand

import android.speech.SpeechRecognizer; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    stt_intent=intent;
    //Initiate speechRecognizer object and start listening
    speechRecognizer = SpeechRecognizer.createSpeechRecognizer(this);
    speechRecognizer.setRecognitionListener(new SpeechListener(this,stt_intent));
    speechRecognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    speechRecognizer.startListening(speechRecognizerIntent);
    Toast.makeText(this, "Speak now", Toast.LENGTH_LONG).show();

    //start foreground notification
    notification = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.skull)
            .setContentTitle("DroidAssistant")
            .setTicker("DroidAssistant")
            .setLargeIcon(BitmapFactory.decodeResource(Resources.getSystem(), R.drawable.skull))
            .setContentText(getString(R.string.sticker)).build();
    startForeground(ONGOING_NOTIFICATION_ID, notification);

    return Service.START_NOT_STICKY;
}
 
开发者ID:cehsonu100,项目名称:DroidAssistant,代码行数:22,代码来源:SpeechToTextService.java

示例12: onCreate

import android.speech.SpeechRecognizer; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mTextView = (TextView) findViewById(R.id.textView);
    findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            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,
                    getPackageName());
            mSpeechRecognizer.startListening(intent);
        }
    });

    mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(this);
    mSpeechRecognizer.setRecognitionListener(myRecognitionListener);

    loadMemo();
}
 
开发者ID:yokmama,项目名称:honki_android,代码行数:25,代码来源:MainActivity.java

示例13: onCreate

import android.speech.SpeechRecognizer; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mTextView = (TextView) findViewById(R.id.textView);
    findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            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,
                    getPackageName());
            mSpeechRecognizer.startListening(intent);
        }
    });

    //音声入力のプロバイダクラスを生成
    mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(this);
    mSpeechRecognizer.setRecognitionListener(myRecognitionListener);

    loadMemo();
}
 
开发者ID:yokmama,项目名称:honki_android,代码行数:26,代码来源:MainActivity.java

示例14: onCreate

import android.speech.SpeechRecognizer; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.lesson35_activity_main);

    mTextView = (TextView) findViewById(R.id.textView);
    findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            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,
                    getPackageName());
            mSpeechRecognizer.startListening(intent);
        }
    });

    //音声入力のプロバイダクラスを生成
    mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(this);
    mSpeechRecognizer.setRecognitionListener(myRecognitionListener);

    loadMemo();
}
 
开发者ID:yokmama,项目名称:honki_android,代码行数:26,代码来源:MainActivity.java

示例15: SpeechRecognition

import android.speech.SpeechRecognizer; //导入方法依赖的package包/类
private SpeechRecognition(long nativeSpeechRecognizerImplAndroid) {
    mContinuous = false;
    mNativeSpeechRecognizerImplAndroid = nativeSpeechRecognizerImplAndroid;
    mListener = new Listener();
    mIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);

    if (sRecognitionProvider != null) {
        mRecognizer = SpeechRecognizer.createSpeechRecognizer(
                ContextUtils.getApplicationContext(), sRecognitionProvider);
    } else {
        // It is possible to force-enable the speech recognition web platform feature (using a
        // command-line flag) even if initialize() failed to find the PROVIDER_PACKAGE_NAME
        // provider, in which case the first available speech recognition provider is used.
        // Caveat: Continuous mode may not work as expected with a different provider.
        mRecognizer =
                SpeechRecognizer.createSpeechRecognizer(ContextUtils.getApplicationContext());
    }

    mRecognizer.setRecognitionListener(mListener);
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:21,代码来源:SpeechRecognition.java


注:本文中的android.speech.SpeechRecognizer.createSpeechRecognizer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。