Add timestamps about streaming models for Swift API (#1113)

This commit is contained in:
Fangjun Kuang 2024-07-12 17:39:46 +08:00 committed by GitHub
parent c0eaf86dbd
commit d928f77d0e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 0 deletions

View File

@ -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
}

View File

@ -91,6 +91,7 @@ func run() {
let result = recognizer.getResult()
print("\nresult is:\n\(result.text)")
print("\nresult is:\n\(result.timestamps)")
}
@main