Skip to content

Commit

Permalink
Updated README added guide for using plugin and changed device select…
Browse files Browse the repository at this point in the history
…ion priorities
  • Loading branch information
this-Aditya committed Aug 1, 2024
1 parent ecc106b commit 75c1602
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 4 deletions.
35 changes: 33 additions & 2 deletions plugins/radar-android-phone-audio-input/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,42 @@ This plugin provides an interactive UI for recording and managing audio data. Be
5. **Device Selection Mechanism**:
- The device selection mechanism automatically prioritizes the USB audio device if connected. If no USB device is found, the plugin selects external devices in the following order of precedence:
- `TYPE_USB_DEVICE`
- `TYPE_BLUETOOTH`
- `TYPE_WIRED_HEADSET`
- If no external device is found, the plugin defaults to using the smartphone's built-in microphone.
- `TYPE_BLUETOOTH`
- If no external device is found, the plugin defaults to using the smartphone's built-in microphone.

6. **Fragment Integration**:
- `PhoneAudioInputActivity` opens a fragment that provides additional capabilities, including:
- **Audio Playback**: Users can playback the recorded audio to review it before sending.
- **Data Sending**: Users can send the recorded audio data for storing to s3.

### Guide for Using the PhoneAudioInput Plugin
<br>
<img src="assets/images/audio_input_plugin/action_devices.jpg" width="200px" alt="action_devices"/>
<img src="assets/images/audio_input_plugin/recording_activity.jpg" width="200px" alt="recording_activity"/>
<br>
1. In the main activity, where plugins are visible along with their actions (if any), click on the specific action for the **Phone Audio Input** plugin.
- This will redirect you to the first activity of the Phone Audio Input plugin.
<br>
<img src="assets/images/audio_input_plugin/recording_activity_devices.jpg" width="200px" alt="recording_activity_devices"/>
<img src="assets/images/audio_input_plugin/recording_activity_paused.jpg" width="200px" alt="recording_activity_paused"/>
<br>
2. At the top of this activity, there is a dropdown menu for selecting microphones.
- The current input routing microphone is shown by default in the dropdown menu when it is collapsed.
- Click on the refresh button near dropdown menu to refresh microphones.
- Select your preferred microphone from the dropdown menu. If no preferred microphone is selected, the automatic device selection logic will take place.
<br>
<img src="assets/images/audio_input_plugin/alert_rec_ongoing.jpg" width="200px" alt="alert_rec_ongoing"/>
<img src="assets/images/audio_input_plugin/alert_rec_stopped.jpg" width="200px" alt="alert_rec_stopped"/>
<br>
3. Click **Start Recording** to begin recording audio.
- While recording, you can pause or resume the recording.
- Do not quit the recording activity while recording is in progress or paused, as this may cause the application to misbehave. An alert will also be shown if you attempt to quit the activity in a recording or paused state. You can safely quit the activity after stopping the recording.
<br>
<img src="assets/images/audio_input_plugin/playback_frag.jpg" width="200px" alt="playback_frag"/>
<img src="assets/images/audio_input_plugin/playback_exit_alert.jpg" width="200px" alt="playback_exit_alert"/>
<br>
4. After stopping the recording, an alert dialog will appear with three options: play the recorded audio, send it directly without playing, or discard it.
- If you click **Play**, you will be redirected to a new fragment for listening to the last recorded audio. Here, you can review the recording and send it after listening.


Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,10 @@ class PhoneAudioInputManager(service: PhoneAudioInputService) : AbstractSourceMa
logger.info("Running device selection logic")
(arrayOf(TYPE_USB_DEVICE, TYPE_USB_HEADSET).let { deviceTypes ->
connectedMicrophones.run { preferByDeviceType(deviceTypes) }
}?: arrayOf(TYPE_WIRED_HEADSET).let { deviceTypes ->
connectedMicrophones.run { preferByDeviceType(deviceTypes) }
} ?: arrayOf(TYPE_BLUETOOTH_A2DP, TYPE_BLUETOOTH_SCO).let { deviceTypes ->
connectedMicrophones.run { preferByDeviceType(deviceTypes) }
} ?: arrayOf(TYPE_WIRED_HEADSET).let { deviceTypes ->
connectedMicrophones.run { preferByDeviceType(deviceTypes) }
} ?: connectedMicrophones.firstOrNull())?.also(setPreferredDeviceAndUpdate)
}

Expand All @@ -278,6 +278,7 @@ class PhoneAudioInputManager(service: PhoneAudioInputService) : AbstractSourceMa
}

private fun clearAudioDirectory() {
payloadSize = 0
audioDir?.let { audioDir ->
audioDir.parentFile
?.list { _, name -> name.startsWith("phone_audio_input") && name.endsWith(".wav") }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,9 @@ class PhoneAudioInputActivity : AppCompatActivity() {
override fun onStop() {
super.onStop()
state?.apply{
isRecording.value?.let {
audioRecordManager?.stopRecording()
}
microphonePrioritized = false
isRecording.postValue(null)
}
Expand Down

0 comments on commit 75c1602

Please sign in to comment.