examples : add whisper.swiftui demo app (#308)

* Add SwiftUI demo project.

* Add -DGGML_USE_ACCELERATE
This commit is contained in:
Digipom
2022-12-23 03:56:18 -05:00
committed by GitHub
parent 4c1fe0c813
commit 0f4227d9ee
18 changed files with 1023 additions and 0 deletions

View File

@ -0,0 +1,12 @@
import Foundation
func decodeWaveFile(_ url: URL) throws -> [Float] {
let data = try Data(contentsOf: url)
let floats = stride(from: 44, to: data.count, by: 2).map {
return data[$0..<$0 + 2].withUnsafeBytes {
let short = Int16(littleEndian: $0.load(as: Int16.self))
return max(-1.0, min(Float(short) / 32767.0, 1.0))
}
}
return floats
}