0

I record an audio input in flutter and need it with different sample rate and a specific frame length in Swift.

I record an audio file with record like:

await record.start(
    encoder: AudioEncoder.wav, // AudioEncoder.aacLc, // by default
    bitRate: 128000, // by default
    samplingRate: 44100, // by default
  );

I will use this audio in Swift for Cobra by picovoice (Cobra is a Voice Activity Detector. So I want to know if somebody said something). This looks like:

var pcm: [Int16] =... // audio file
let result:Float32 = try self.cobra!.process(pcm: pcm)

The "pcm" need to be a [Int16] of the audio with a sample rate of 16000 and a frame length of 512.

  1. When I change the samplingRate in record.start() from 44100 to 16000, I get an error.
  2. As I understand the "frame length", it is the length of the audio. So am I correct if I just cut the audio after 512 frames?
kemmel
  • 35
  • 6

0 Answers0