Invalid file format for iOS recording

I am facing an issue that has been described elsewhere in this forum, but I haven’t seen an iOS-native solution. I am using SwiftUI and the AVAudioRecorder to capture audio. I have used various settings, such as the ones below:

private var settings: [String: Any] {
    switch RecordingQuality(rawValue: quality) {
    case .high:
      return [
        AVFormatIDKey: Int(kAudioFormatLinearPCM),
        AVSampleRateKey: 44_100,
        AVNumberOfChannelsKey: 1,
        AVLinearPCMBitDepthKey: 16,
        AVLinearPCMIsBigEndianKey: false,
        AVLinearPCMIsFloatKey: false,
      ]
    case .medium, .low, .none:
      return [
        AVFormatIDKey: Int(kAudioFormatMPEG4AAC),
        AVSampleRateKey: 44_100,
        AVNumberOfChannelsKey: 1,
        AVEncoderAudioQualityKey: AVAudioQuality.high.rawValue,
      ]
    }
  }

I am using a 3rd party application to upload the recordings. No matter which setting I am using, I always end up with something along these lines

Invalid file format. Supported formats: ['flac', 'm4a', 'mp3', 'mp4', 'mpeg', 'mpga', 'oga', 'ogg', 'wav', 'webm']

Has anyone managed to configure settings for the AVAudioRecorder that result in success when using the Whisper API? Thanks!

1 Like

I’m currently developing an iOS app focused on dictation because most of the apps in the App Store are focusing on transcription of uploaded files and still want this feature

though but in any case yeah I’ve also noticed this when trying to pass a Siri shortcut recorded audio file. been doing some research for the past few days and it looks like it’s because the specific iOS implementation in the whisper CPP examples takes a very specific wav format when it does the recording so right now it looks like that the solution is to convert m4a or any other file type into that specific format, but not just the format, the same parameters of the wav file

will highlight here the conversion parameters in Swift once I figure it out.