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
This commit is contained in:
Fangjun Kuang
2023-04-05 22:16:29 +08:00
committed by GitHub
parent ae1f9e7914
commit 9ac747248b
19 changed files with 1097 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
//
// 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()
}
}