mirror of
https://github.com/FluidInference/FluidAudio.git
synced 2026-05-12 20:20:36 +00:00
4e8b54ed78
### 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
838 B
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.