Description
Package version: ^5.0.4
Environment
- OS: Android/iOSl
Describe the bug
I am trying to use the record
library to transcribe audio in realtime. I want to send the stream of audio in PCM16 format over websockets to a custom server, which will then send it to a Speech-to-Text service. However, doing a stream.listen
on
final AudioRecorder _recorder = AudioRecorder();
final stream = await _recorder.startStream(const RecordConfig(
encoder: AudioEncoder.pcm16bits,
sampleRate: 48000,
));
returns a Uint8List
which does not work well since the service expects PCM16 to be a 16bit list.
So far, I have tried _recorder.convertBytesToInt16(chunk)
, a for loop that just sends the data one 8bit int at a time, chunk.buffer.toInt8List()
, and just sending the chunk.buffer
as is, but nothing has worked.
Expected behavior
Ideally, the resulting stream from the PCM16 encoding should be an Int16List to reflect the true nature of the data, but this oversight seems to be there in all the recording libraries for some reason. How could I go about solving this? How can I extract the 16 bit integers for PCM16 from this Uint8List
?