예제 #1
0
        public void onResult(RecognizerResult results, boolean isLast) {

          Log.e(">>>>>>>解析>>>>>>>>", results.getResultString());

          String text = JsonParser.parseIatResult(results.getResultString());
          // 向服务器发送消息
          if (text != null && text != "") {
            center.setText(text);
            Log.e("----------", text);
            if (text != null && !text.equals("")) {
              socket.sendMessage(DataParse.toJson("register", "admin", text));
            } else {
              socket.sendMessage(DataParse.toJson("register", "admin", "用户没有说话"));
            }
          }
          try {
            Thread.sleep(3000);
          } catch (InterruptedException e) {
            e.printStackTrace();
          }

          // 唤醒语音播放
          String callbackresult = socket.getMessage();
          if (callbackresult.contains("0x5a")) {
            Message msg = new Message();
            msg.what = 0;
            msg.obj = callbackresult;
            handler.sendMessage(msg);
          }
        }
예제 #2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    socket = new ClientSocket();
    socket.start();

    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);

    setContentView(R.layout.activity_recode);
    center = (TextView) findViewById(R.id.login_speech_text);
    imageView = (ImageView) findViewById(R.id.login_center_image);

    // 语音初始化
    initSpeech();

    handler.sendEmptyMessage(0);
  }