Canardoux / flutter_sound

Flutter plugin for sound. Audio recorder and player.
Mozilla Public License 2.0
880 stars 576 forks source link

[HELP]How to record truely in .wav format audio #973

Open islom9797 opened 1 year ago

islom9797 commented 1 year ago

How to record in .wav format audio

Here is my question :

Directory tempDir = await getApplicationDocumentsDirectory();

String path = tempDir.path + '/audio.wav'; mRecorder?.startRecorder(toFile: path, codec: Codec.pcm16WAV) this source dont give any error but when I stop record value(path of recorded audio) is empty

await mRecorder!.stopRecorder().then((value) async { print('value on stopRecord $value');

sofakeer commented 1 year ago

it work

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 90 days with no activity. Leave a comment or this will be closed in 7 days.

github-actions[bot] commented 8 months ago

This issue is stale because it has been open 365 days with no activity. Leave a comment or this will be closed in 7 days.

RitchieP commented 7 months ago

@islom9797 Hi, have you happen to make this work? I'm also facing the same issue

muneebahmad0600 commented 2 months ago

@Larpoux @RitchieP @islom9797 Having same issue. ` void startRecorder() async { if (_mRecorder!.recorderState == RecorderState.isPaused) { resumeRecorder(); return; } Directory tempDir = await getApplicationDocumentsDirectory(); _mRecorder! .startRecorder( toFile: '${tempDir.path}/audio.wav', codec: Codec.pcm16WAV, audioSource: theSource, ) .then((value) { setState(() { _isRecording = true; context.read().toggleTimer(); }); }); }

void stopRecorder() async { await _mRecorder!.stopRecorder().then((value) { context.read().pauseTimer(); setState(() { _recordingPath = value.toString(); _isRecording = false; Timer(const Duration(milliseconds: 500), () { NavigationService.pushReplacement( UploadRecordingScreen(recordingPath: _recordingPath), ); }); }); }); }`

value is empty string when recording is stopped. @sofakeer please reply if you can help

Larpoux commented 2 months ago

Actually, I know that there is a bug in Flutter Sound when the App tries to use the File Path returned by stopRecorder().

This is perhaps the reason for your issue. I will work on that point tomorrow. Sorry for the bug.

RitchieP commented 2 months ago

It's been quite a while since I worked on my project that required voice recording. I managed to make it work towards the end but I forgot what was the exact issue.

But I can share the link to my source code if you'd like to have a look.

https://github.com/RitchieP/VerbaLex/blob/main/verbalex/lib/utils/record_voice.dart

Larpoux commented 2 months ago

I am currently in the process of releasing a new flutter sound version with a bug fixed on Android with PCM16-WAV. The new version will be accessible in half an hour. I think that it will solve your issue.

Larpoux commented 2 months ago

Flutter Sound 9.16.1 is released :

9.16.1

muneebahmad0600 commented 1 month ago

Issue fixed. Thanks @Larpoux. very much appreciated man