Skip to content

Commit

Permalink
Add timestamps about streaming models for Swift API (#1113)
Browse files Browse the repository at this point in the history
  • Loading branch information
csukuangfj authored Jul 12, 2024
1 parent c0eaf86 commit d928f77
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions swift-api-examples/SherpaOnnx.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions swift-api-examples/decode-file.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ func run() {

let result = recognizer.getResult()
print("\nresult is:\n\(result.text)")
print("\nresult is:\n\(result.timestamps)")
}

@main
Expand Down

0 comments on commit d928f77

Please sign in to comment.