/** 开始录音 */
  private void startRecong() {
    setiFlytekParam();
    if (null == mRecognizerDialog) {
      // 初始化听写Dialog,如果只使用有UI听写功能,无需创建SpeechRecognizer
      mRecognizerDialog = new RecognizerDialog(this, miFlytekInitListener);
    }

    // 显示听写对话框
    mRecognizerDialog.setListener(mRecognizerDialogListener);
    mRecognizerDialog.setOnDismissListener(mOnDismissListener);
    mRecognizerDialog.show();
  }
Esempio n. 2
0
 /** 识别回调错误. */
 public void onError(SpeechError error) {
   iatDialog.dismiss();
   // 录入语音错误返回
   Message msg = new Message();
   msg.what = 0;
   msg.obj = "您好像没有说话哦!请重新录入";
   handler.sendMessage(msg);
 }
Esempio n. 3
0
        @Override
        public void handleMessage(Message msg) {
          // TODO Auto-generated method stub
          // 朗读 (语音合成)
          if (msg.what == 0) {

            showFrame(1);
            animListen.setOneShot(false);

            if (msg.obj == null) {
              text = "您好,验光开始,请在三秒后说话。。。。。。";
              playSpeech(text);
            } else {
              text = (String) msg.obj;
              playSpeech(text);
            }
          }
          // 录音(语音识别)
          if (msg.what == 1) {
            setParam();
            boolean isShowDialog = true;
            // showFrame(2);
            if (isShowDialog) {
              // 显示听写对话框
              iatDialog.setListener(recognizerDialogListener);
              iatDialog.show();
            } else {
              // 不显示听写对话框
              ret = mIat.startListening(recognizerListener);
              if (ret != ErrorCode.SUCCESS) {
                Toast.makeText(RecodeActivity.this, "听写失败,错误码:" + ret, Toast.LENGTH_LONG).show();
              } else {
                Toast.makeText(RecodeActivity.this, "begin" + ret, Toast.LENGTH_LONG).show();
              }
            }
          }
        }