ContentView.swift
1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//
// ContentView.swift
// SherpaOnnxLangID
//
// Created by knight on 2024/4/1.
//
import SwiftUI
struct ContentView: View {
@StateObject var viewModel = ViewModel()
var body: some View {
VStack {
Text("ASR with Next-gen Kaldi")
.font(.title)
if viewModel.status == .stop {
Text("See https://github.com/k2-fsa/sherpa-onnx")
Text("Press the Start button to run!")
}
if viewModel.status == .recording {
Text("Stop will show recording language.")
}
Spacer()
Text("Recording language is: \(viewModel.language)")
.frame(maxWidth: .infinity)
Spacer()
Button {
toggleRecorder()
} label: {
Text(viewModel.status == .stop ? "Start" : "Stop")
}
}
.padding()
}
private func toggleRecorder() {
Task {
await viewModel.toggleRecorder()
}
}
}
#Preview {
ContentView()
}