This repository has been archived on 2025-08-26. You can view files and clone it, but cannot push or open issues or pull requests.
Files
enginex-mr_series-sherpa-onnx/ios-swiftui/SherpaOnnx/SherpaOnnx/ContentView.swift
Fangjun Kuang 9ac747248b Add SwiftUI demo project (#118)
* Commit after creating the project

* Add sherpa-onnx related files

* copy and modify files from sherpa-ncnn

* add app icon
2023-04-05 22:16:29 +08:00

47 lines
1.1 KiB
Swift

//
// ContentView.swift
// SherpaOnnx
//
// Created by fangjun on 2023/4/5.
//
import SwiftUI
struct ContentView: View {
@StateObject var sherpaOnnxVM = SherpaOnnxViewModel()
var body: some View {
VStack {
Text("ASR with Next-gen Kaldi")
.font(.title)
if sherpaOnnxVM.status == .stop {
Text("See https://github.com/k2-fsa/sherpa-onnx")
Text("Press the Start button to run!")
}
ScrollView(.vertical, showsIndicators: true) {
HStack {
Text(sherpaOnnxVM.subtitles)
Spacer()
}
}
Spacer()
Button {
toggleRecorder()
} label: {
Text(sherpaOnnxVM.status == .stop ? "Start" : "Stop")
}
}
.padding()
}
private func toggleRecorder() {
sherpaOnnxVM.toggleRecorder()
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}