mirror of
https://github.com/k2-fsa/sherpa-onnx.git
synced 2026-01-09 07:41:06 +08:00
Add timestamps about streaming models for Swift API (#1113)
This commit is contained in:
parent
c0eaf86dbd
commit
d928f77d0e
@ -194,6 +194,19 @@ class SherpaOnnxOnlineRecongitionResult {
|
||||
}
|
||||
}
|
||||
|
||||
var timestamps: [Float] {
|
||||
if let p = result.pointee.timestamps {
|
||||
var timestamps: [Float] = []
|
||||
for index in 0..<count {
|
||||
timestamps.append(p[Int(index)])
|
||||
}
|
||||
return timestamps
|
||||
} else {
|
||||
let timestamps: [Float] = []
|
||||
return timestamps
|
||||
}
|
||||
}
|
||||
|
||||
init(result: UnsafePointer<SherpaOnnxOnlineRecognizerResult>!) {
|
||||
self.result = result
|
||||
}
|
||||
|
||||
@ -91,6 +91,7 @@ func run() {
|
||||
|
||||
let result = recognizer.getResult()
|
||||
print("\nresult is:\n\(result.text)")
|
||||
print("\nresult is:\n\(result.timestamps)")
|
||||
}
|
||||
|
||||
@main
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user