4
votes

I'm developping an application that aims to record speech using a bluetooth headset microphone. I'm using Ionic 2 with this environment :

@ionic/cli-utils : 1.4.0
Cordova CLI      : 7.0.1
Ionic CLI        : 3.4.0
local packages:

@ionic/app-scripts              : 1.1.4
@ionic/cli-plugin-cordova       : 1.4.0
@ionic/cli-plugin-ionic-angular : 1.3.1
Cordova Platforms               : android 6.1.2
Ionic Framework                 : ionic-angular 2.2.0
System:

Node       : v6.10.0
OS         : Windows 10
npm        : 3.10.10

I'm using cordova-plugin-audioinput to record the audio. I've tried to change the audio input source type of the configuration to VOICE_COMMUNICATION, MIC and DEFAULT. However, it's still recording with the device's microphone.

On Android, I've seen that MediaRecorder is used. I've tried to set the audioinput source to VOICE_CALL after reading it but the app crashed.

Finally, I found this link. I would like to know if there is any cordova plugin to do this? Is there a way to record audio from a bluetooth headset microphone using Ionic 2?

Thanks in advance

1
Hello,Did you find any solution for this? - Sujay
Hello, unfortunately no. I don't think that is possible.. - Chris
I find this appalling? Did you figure this out yet? - user3788941
@Chris, can you please de-accept the answer and re-institute my bounty? His answer does not work - user3788941
I'm no longer working on this project :/ - Chris

1 Answers

3
votes

There's no cordova wrapper known for that purpose. What you could do is controlling the device directly through AT commands. Basically, what Android does if you follow this documentation :

https://developer.android.com/reference/android/bluetooth/BluetoothHeadset.html

is sending AT commands to the Headphone through Serial Communication. You could use https://github.com/don/BluetoothSerial to send and read RAW buffer from the bluetooth headset. You could for example send an AT command which will start the microphone recording on your headset, then get the RAW audio from the received buffers, then with the help of others libraries transform the RAW data to mp3.

If you want to read more about Serial Communication over bluetooth and especially AT commands : http://www.spezial.cz/pdf/Serial_Port_Adapter_AT_Commands.pdf