I am trying to record audio through mic_stream package in pub.dev (since I want 16000Hz PCM data), and trying to capture data and send it to Nodejs server. I am not making any changes to the mic_stream example in the provided link, but I want to send the audio data in 16000Hz PCM format to Nodejs server. I have tried using http.MultipartFile as shown below:
var url = Uri.parse("http://localhost:3000/upload");
var request = new http.MultipartRequest("POST", url);
Future<int> length = stream.length;
var stream_length = http.ByteStream(stream);
request.files.add( await http.MultipartFile('music',stream,length,{
"filename1234.pcm"), new MediaType('audio', 'x-wav')});
//This gives me error because length is not of int type
request.send().then((response) {
print("test");
if (response.statusCode == 200) print("Uploaded! ${response}");
else print("Failure");
});
I want to know if this works or if there are any other packages that I can use to record the data and send to Nodejs in PCM format 16000Hz. Any help is highly appreciated.