Canardoux / flutter_sound

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

I have a requirement, I need record pcm and convert pcm to base64 and upload it to the server. #276

Closed liyang1518 closed 4 years ago

liyang1518 commented 4 years ago

Version of flutter_sound

flutter doctor

Platforms you faced the error (IOS or Android or both?)

Expected behavior

Actual behavior

Tested environment (Emulator? Real Device?)

Steps to reproduce the behavior

Larpoux commented 4 years ago

Actually, flutter_sound can only record AAC, and OPUS on Android. We plan to add more codes. PCM is probably the next codec that we will support because we think that it will not very difficult to implement.

Please, keep this issue open, and be patient ...

Larpoux commented 4 years ago

Sorry, OPUS on iOS

liyang1518 commented 4 years ago

forwording... I tried to use multiple solutions to solve the Flutter speech recognition function. The original Google and IOS native speech recognition functions were used, but it is difficult to use on different brands of Android machines. Second, the most convenient solution uses the SDK to convert voice files to text in real time, but the three-party voice vendors purchased by the company do not support Flutter, and only support the analysis of PCM (WAV) files. So it can only be mixed development. At the beginning, I used flutter_ffmpeg to transcode the AAC file, but the file will be damaged and cannot be parsed, waiting for you to record PCM.

Larpoux commented 4 years ago

Yes, implementing PCM recording should not be too much difficult. But better, should be to to stream the record to the server during the recording and not after. But doing that is a major development, and this will be in flutter_sound 4.x.x

liyang1518 commented 4 years ago

You reminded me that flutter_sound provides encoded files and needs to be expanded. I am going to use websocket to implement it. in adnroid,AudioRecord performs recording and broadcasting while processing audio in real time.

Larpoux commented 4 years ago

It will be great if you have something that you develop and can be integrated inside flutter_sound.

Larpoux commented 4 years ago

Flutter Sound 3.1.6 on iOS can record PCM. Unfortunately, this is not easy to implement on Android. Maybe a future version will do it ?

kame5 commented 4 years ago

Just question, will PCM on Andriod be released soon or not? I need a lossless encoder to do speech analysis.

Larpoux commented 4 years ago

This is the first feature on top of the list that I want to develop. This is bad that PCM is almost completely supported except recording on Android. Unfortunately I do not know if it will be difficult to implement. Actually, I think that I will have to say "good-bye" to the f***ing Android Media Player. So I cannot tell you the delay waiting.

Thank you to have confirmed that PCM on Android is a priority.

Larpoux commented 4 years ago

on Flutter Sound V5.0.0 it will be possible to record PCM-linear16 (raw, Wave or AIFF). It will be also possible to record raw PCM to a Dart Stream, instead of a file. This version is supposed to be released sometime next week.

What is your base64 conversion ? Do you think it is Flutter Sound responsability to take care of that ? Or is this the App responsability ?

felixjunghans commented 4 years ago

I have the same use case and currently use flutter_audio_recorder. I would be happy to switch to flutter_sound in the future and am therefore very excited about version 5.x.

I think converting the audio file to Base64 is a matter for the app, because it is only used for special scenarios. But it is not a big problem as it is only one line of code.

import 'dart:convert';

base64Encode(file.readAsBytesSync())
liyang1518 commented 4 years ago

flutter_sound 5.X.X solved my problem .Thanks to the author, close the question