-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathmedasr-ctc.swift
More file actions
42 lines (34 loc) · 1 KB
/
medasr-ctc.swift
File metadata and controls
42 lines (34 loc) · 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
func run() {
let model =
"./sherpa-onnx-medasr-ctc-en-int8-2025-12-25/model.int8.onnx"
let tokens =
"./sherpa-onnx-medasr-ctc-en-int8-2025-12-25/tokens.txt"
let medasr = sherpaOnnxOfflineMedAsrCtcModelConfig(
model: model
)
let modelConfig = sherpaOnnxOfflineModelConfig(
tokens: tokens,
debug: 1,
medasr: medasr
)
let featConfig = sherpaOnnxFeatureConfig()
var config = sherpaOnnxOfflineRecognizerConfig(
featConfig: featConfig,
modelConfig: modelConfig
)
let recognizer = SherpaOnnxOfflineRecognizer(config: &config)
let filePath = "./sherpa-onnx-medasr-ctc-en-int8-2025-12-25/test_wavs/0.wav"
let audio = SherpaOnnxWaveWrapper.readWave(filename: filePath)
let result = recognizer.decode(samples: audio.samples, sampleRate: audio.sampleRate)
print("decode done")
print("\nresult is:\n\(result.text)")
if result.timestamps.count != 0 {
print("\ntimestamps is:\n\(result.timestamps)")
}
}
@main
struct App {
static func main() {
run()
}
}