BasedHardware / Friend

AI wearable necklace
https://basedhardware.com
MIT License
2.04k stars 219 forks source link

Creating memories using phone microphone (Finish feature) ($100) #348

Open josancamon19 opened 6 days ago

josancamon19 commented 6 days ago

Is your feature request related to a problem? Please describe. This feature was started but not finished.

// widgets.dart
getPhoneMicRecordingButton(VoidCallback recordingToggled, RecordState state) {
  if (SharedPreferencesUtil().deviceId.isNotEmpty) return const SizedBox.shrink();
  return Visibility(
    visible: false, // set this to visible: true, when you start testing.

capture/page.dart ~ _recordingToggled

This was attempted using flutter_sound and record libraries, no success.

Describe the solution you'd like The button should be able to start and stop recording from the device, every 30 seconds the current file/audio bytes, should be processed and _processFileToTranscript should be called.

This is it, this will start displaying the transcripts as if it was coming from the device. THIS MUST WORK IN THE BACKGROUND. Android and iOS.

mdmohsin7 commented 6 days ago

This was attempted using flutter_sound and record libraries, no success.

What issue exactly are you facing? I uncommented your code and commented out _processFileToTranscript(f) call and instead tried playing the recorded audio, and it is playing without any issues

mdmohsin7 commented 5 days ago

I sort of completed the functionality, and this how the output is. Can you please check if this is the expected output?

https://github.com/BasedHardware/Friend/assets/59914433/51aa40a5-8e74-4938-b267-d779e820867a

josancamon19 commented 5 days ago

Hey @mdmohsin7 if you put the app in the background unfortunately it doesn't work, that's what needs to be fixed.

mdmohsin7 commented 5 days ago

Hey @mdmohsin7 if you put the app in the background unfortunately it doesn't work, that's what needs to be fixed.

I see. When I uncommented _processFileToTranscript(f) call, deepgram was returning an error Bad Request: failed to process audio: corrupt or unsupported data. So something is wrong with the audio file.

I changed implementation to only use record package to record audio and send it to deepgram, and it was working fine without any issues.

mdmohsin7 commented 5 days ago

Got it working on Android, battery optimisation stuff is there that has to be addressed. Once I finish iOS specific things as well, I'll open a PR

https://github.com/BasedHardware/Friend/assets/59914433/731bca22-526f-4636-9a27-5c57eddade15

josancamon19 commented 4 days ago

Nice, what do you mean by android optimization issues? would the user have to set that up on the settings? @mdmohsin7

mdmohsin7 commented 4 days ago

Nice, what do you mean by android optimization issues? would the user have to set that up on the settings? @mdmohsin7

Yes! Android doesn't let any app run in the background for long periods to improve battery life. For apps that need to run in the background for extended periods, they must prompt the user to disable battery optimization for that specific app through the settings. The user will have to do this manually in the settings.

We can just use this instead of writing the native code: https://pub.dev/packages/disable_battery_optimization