mirror of
https://github.com/ggerganov/whisper.cpp.git
synced 2024-12-27 07:52:27 +00:00
0f4227d9ee
* Add SwiftUI demo project. * Add -DGGML_USE_ACCELERATE
44 lines
1.3 KiB
Swift
44 lines
1.3 KiB
Swift
import SwiftUI
|
|
import AVFoundation
|
|
|
|
struct ContentView: View {
|
|
@StateObject var whisperState = WhisperState()
|
|
|
|
var body: some View {
|
|
NavigationStack {
|
|
VStack {
|
|
HStack {
|
|
Button("Transcribe", action: {
|
|
Task {
|
|
await whisperState.transcribeSample()
|
|
}
|
|
})
|
|
.buttonStyle(.bordered)
|
|
.disabled(!whisperState.canTranscribe)
|
|
|
|
Button(whisperState.isRecording ? "Stop recording" : "Start recording", action: {
|
|
Task {
|
|
await whisperState.toggleRecord()
|
|
}
|
|
})
|
|
.buttonStyle(.bordered)
|
|
.disabled(!whisperState.canTranscribe)
|
|
}
|
|
|
|
ScrollView {
|
|
Text(verbatim: whisperState.messageLog)
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
}
|
|
}
|
|
.navigationTitle("Whisper SwiftUI Demo")
|
|
.padding()
|
|
}
|
|
}
|
|
}
|
|
|
|
struct ContentView_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
ContentView()
|
|
}
|
|
}
|