Add swift online punctuation (#1661)
This commit is contained in:
@@ -1095,6 +1095,52 @@ class SherpaOnnxOfflinePunctuationWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
func sherpaOnnxOnlinePunctuationModelConfig(
|
||||
cnnBiLstm: String,
|
||||
bpeVocab: String,
|
||||
numThreads: Int = 1,
|
||||
debug: Int = 0,
|
||||
provider: String = "cpu"
|
||||
) -> SherpaOnnxOnlinePunctuationModelConfig {
|
||||
return SherpaOnnxOnlinePunctuationModelConfig(
|
||||
cnn_bilstm: toCPointer(cnnBiLstm),
|
||||
bpe_vocab: toCPointer(bpeVocab),
|
||||
num_threads: Int32(numThreads),
|
||||
debug: Int32(debug),
|
||||
provider: toCPointer(provider))
|
||||
}
|
||||
|
||||
func sherpaOnnxOnlinePunctuationConfig(
|
||||
model: SherpaOnnxOnlinePunctuationModelConfig
|
||||
) -> SherpaOnnxOnlinePunctuationConfig {
|
||||
return SherpaOnnxOnlinePunctuationConfig(model: model)
|
||||
}
|
||||
|
||||
class SherpaOnnxOnlinePunctuationWrapper {
|
||||
/// A pointer to the underlying counterpart in C
|
||||
let ptr: OpaquePointer!
|
||||
|
||||
/// Constructor taking a model config
|
||||
init(
|
||||
config: UnsafePointer<SherpaOnnxOnlinePunctuationConfig>!
|
||||
) {
|
||||
ptr = SherpaOnnxCreateOnlinePunctuation(config)
|
||||
}
|
||||
|
||||
deinit {
|
||||
if let ptr {
|
||||
SherpaOnnxDestroyOnlinePunctuation(ptr)
|
||||
}
|
||||
}
|
||||
|
||||
func addPunct(text: String) -> String {
|
||||
let cText = SherpaOnnxOnlinePunctuationAddPunct(ptr, toCPointer(text))
|
||||
let ans = String(cString: cText!)
|
||||
SherpaOnnxOnlinePunctuationFreeText(cText)
|
||||
return ans
|
||||
}
|
||||
}
|
||||
|
||||
func sherpaOnnxOfflineSpeakerSegmentationPyannoteModelConfig(model: String)
|
||||
-> SherpaOnnxOfflineSpeakerSegmentationPyannoteModelConfig
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user