-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathfire-red-asr-ctc.swift
More file actions
42 lines (34 loc) · 1.05 KB
/
fire-red-asr-ctc.swift
File metadata and controls
42 lines (34 loc) · 1.05 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-fire-red-asr2-ctc-zh_en-int8-2026-02-25/model.int8.onnx"
let tokens =
"./sherpa-onnx-fire-red-asr2-ctc-zh_en-int8-2026-02-25/tokens.txt"
let fireRedAsrCtc = sherpaOnnxOfflineFireRedAsrCtcModelConfig(
model: model
)
let modelConfig = sherpaOnnxOfflineModelConfig(
tokens: tokens,
debug: 1,
fireRedAsrCtc: fireRedAsrCtc
)
let featConfig = sherpaOnnxFeatureConfig()
var config = sherpaOnnxOfflineRecognizerConfig(
featConfig: featConfig,
modelConfig: modelConfig
)
let recognizer = SherpaOnnxOfflineRecognizer(config: &config)
let filePath = "./sherpa-onnx-fire-red-asr2-ctc-zh_en-int8-2026-02-25/test_wavs/1.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()
}
}