Fangjun Kuang
Committed by GitHub

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

@@ -194,6 +194,19 @@ class SherpaOnnxOnlineRecongitionResult { @@ -194,6 +194,19 @@ class SherpaOnnxOnlineRecongitionResult {
194 } 194 }
195 } 195 }
196 196
  197 + var timestamps: [Float] {
  198 + if let p = result.pointee.timestamps {
  199 + var timestamps: [Float] = []
  200 + for index in 0..<count {
  201 + timestamps.append(p[Int(index)])
  202 + }
  203 + return timestamps
  204 + } else {
  205 + let timestamps: [Float] = []
  206 + return timestamps
  207 + }
  208 + }
  209 +
197 init(result: UnsafePointer<SherpaOnnxOnlineRecognizerResult>!) { 210 init(result: UnsafePointer<SherpaOnnxOnlineRecognizerResult>!) {
198 self.result = result 211 self.result = result
199 } 212 }
@@ -91,6 +91,7 @@ func run() { @@ -91,6 +91,7 @@ func run() {
91 91
92 let result = recognizer.getResult() 92 let result = recognizer.getResult()
93 print("\nresult is:\n\(result.text)") 93 print("\nresult is:\n\(result.text)")
  94 + print("\nresult is:\n\(result.timestamps)")
94 } 95 }
95 96
96 @main 97 @main