【问题标题】:Continuos Android Speech Recognition with Bluetooth Connections具有蓝牙连接的持续 Android 语音识别
【发布时间】:2017-07-11 09:47:04
【问题描述】:

我正在使用 Google 语音识别实现离线 Continuos 语音识别 Android 应用程序,以管理通过蓝牙连接到 smartphpone 的 Arduino 设备。 当我使用蓝牙耳机时,我想使用蓝牙麦克风而不是手机麦克风。 我指定了以下代码:

private BluetoothProfile.ServiceListener mProfileListener = new BluetoothProfile.ServiceListener() {
    public void onServiceConnected(int profile, BluetoothProfile proxy) {
        if (profile == BluetoothProfile.HEADSET) {
            mBluetoothHeadset = (BluetoothHeadset) proxy;
        }
    }
    @Override
    public void onServiceDisconnected(int profile) {
        if (profile == BluetoothProfile.HEADSET) {
            mBluetoothHeadset = null;
        }
    }
};

和蓝牙耳机接收器:

public class BluetoothHeadsetReceiver extends BroadcastReceiver {

    public BluetoothHeadsetReceiver(Context context) {
        IntentFilter intentFilter = new IntentFilter(BluetoothHeadset.ACTION_AUDIO_STATE_CHANGED);        intentFilter.addAction(BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED);         intentFilter.addAction(BluetoothHeadset.ACTION_VENDOR_SPECIFIC_HEADSET_EVENT);
        context.registerReceiver(this, intentFilter);
        mBluetoothHeadsetReceiver = true;
    }
    public void onReceive(Context context, Intent intent) {
        int state = intent.getIntExtra(BluetoothHeadset.EXTRA_STATE, BluetoothHeadset.STATE_AUDIO_DISCONNECTED);
        if (state == BluetoothHeadset.STATE_AUDIO_CONNECTED) {
            deviceBTName = mBluetoothHeadset.getConnectedDevices().get(0).getName();
            deviceBT = mBluetoothHeadset.getConnectedDevices().get(0);
            audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
            audioManager.startBluetoothSco();
            audioManager.setBluetoothScoOn(true);
            audioManager.setMicrophoneMute(true);
          }
        }
        else if (state == BluetoothHeadset.STATE_AUDIO_DISCONNECTED)
        {
            audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
            audioManager.startBluetoothSco();
            audioManager.setBluetoothScoOn(true);
            mBluetoothConnected = false;
        }
    }
}

但应用程序始终使用电话麦克风。

如何通过蓝牙麦克风路由语音输入? 谢谢

【问题讨论】:

    标签: android bluetooth speech-recognition voice-recognition google-text-to-speech


    【解决方案1】:

    解决方法:audioManager.setSpeakerphoneOn(false);

    【讨论】:

      猜你喜欢
      • 2011-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-06
      • 1970-01-01
      相关资源
      最近更新 更多