Add language identification swiftui demo (#729)

This commit is contained in:
yujinqiu
2024-04-01 20:34:14 +08:00
committed by GitHub
parent fabd30e3bb
commit f8832cb5f2
16 changed files with 1057 additions and 0 deletions

View File

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