コード例 #1
0
  @Override
  public void onClick(View view) {
    switch (view.getId()) {
        // 进入参数设置页面
      case R.id.image_understander_set:
        Intent intent = new Intent(UnderstanderDemo.this, UnderstanderSettings.class);
        startActivity(intent);
        break;
        // 开始文本理解
      case R.id.text_understander:
        mUnderstanderText.setText("");
        String text = "合肥明天的天气怎么样?";
        showTip(text);

        if (mTextUnderstander.isUnderstanding()) {
          mTextUnderstander.cancel();
          showTip("取消");
        } else {
          ret = mTextUnderstander.understandText(text, textListener);
          if (ret != 0) {
            showTip("语义理解失败,错误码:" + ret);
          }
        }
        break;
        // 开始语音理解
      case R.id.start_understander:
        mUnderstanderText.setText("");
        // 设置参数
        setParam();

        if (mSpeechUnderstander.isUnderstanding()) { // 开始前检查状态
          mSpeechUnderstander.stopUnderstanding();
          showTip("停止录音");
        } else {
          ret = mSpeechUnderstander.startUnderstanding(mRecognizerListener);
          if (ret != 0) {
            showTip("语义理解失败,错误码:" + ret);
          } else {
            showTip(getString(R.string.text_begin));
          }
        }
        break;
        // 停止语音理解
      case R.id.understander_stop:
        mSpeechUnderstander.stopUnderstanding();
        showTip("停止语义理解");
        break;
        // 取消语音理解
      case R.id.understander_cancel:
        mSpeechUnderstander.cancel();
        showTip("取消语义理解");
        break;
      default:
        break;
    }
  }
コード例 #2
0
 public boolean is_starting() {
   return m_understander.isUnderstanding();
 }
コード例 #3
0
 public void stop() {
   if (m_understander.isUnderstanding()) m_understander.stopUnderstanding();
 }
コード例 #4
0
 public void start(XFUnderstanderListener listener) {
   if (!m_understander.isUnderstanding()) m_understander.startUnderstanding(listener);
 }