Files
FluidAudio/Documentation/Guides/AudioConversion.md
T
Brandon Weng 4e8b54ed78 Clean up README (#98)
### Why is this change needed?
<!-- Explain the motivation for this change. What problem does it solve?
-->

Readme has grown way too much, splitting it up to just preserve the
essence and move the verbose and details to Documentation
2025-09-11 10:11:25 -04:00

838 B

Audio Conversion (16 kHz mono)

Most FluidAudio features expect 16 kHz mono Float32 samples. Use AudioConverter to load and convert from any AVAudioFile format.

Swift Example

import AVFoundation
import FluidAudio

public func loadSamples16kMono(path: String) async throws -> [Float] {
    let url = URL(fileURLWithPath: path)
    let file = try AVAudioFile(forReading: url)
    let capacity = AVAudioFrameCount(file.length)
    guard let buf = AVAudioPCMBuffer(pcmFormat: file.processingFormat, frameCapacity: capacity) else {
        return []
    }
    try file.read(into: buf)
    let converter = AudioConverter()
    return try await converter.convertToAsrFormat(buf)
}

Notes:

  • Input can be any PCM format supported by AVAudioFile.
  • Output is 16 kHz mono Float32 samples suitable for ASR/VAD/Diarization.