Fix various language binding APIs for tdnn and whisper models (#278)
This commit is contained in:
@@ -51,6 +51,32 @@ namespace SherpaOnnx
|
||||
public string Model;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct OfflineWhisperModelConfig
|
||||
{
|
||||
public OfflineWhisperModelConfig()
|
||||
{
|
||||
Encoder = "";
|
||||
Decoder = "";
|
||||
}
|
||||
[MarshalAs(UnmanagedType.LPStr)]
|
||||
public string Encoder;
|
||||
|
||||
[MarshalAs(UnmanagedType.LPStr)]
|
||||
public string Decoder;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct OfflineTdnnModelConfig
|
||||
{
|
||||
public OfflineWhisperModelConfig()
|
||||
{
|
||||
Model = "";
|
||||
}
|
||||
[MarshalAs(UnmanagedType.LPStr)]
|
||||
public string Model;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct OfflineLMConfig
|
||||
{
|
||||
@@ -73,6 +99,8 @@ namespace SherpaOnnx
|
||||
Transducer = new OfflineTransducerModelConfig();
|
||||
Paraformer = new OfflineParaformerModelConfig();
|
||||
NeMoCtc = new OfflineNemoEncDecCtcModelConfig();
|
||||
Whisper = new OfflineWhisperModelConfig();
|
||||
Tdnn = new OfflineTdnnModelConfig();
|
||||
Tokens = "";
|
||||
NumThreads = 1;
|
||||
Debug = 0;
|
||||
@@ -82,6 +110,8 @@ namespace SherpaOnnx
|
||||
public OfflineTransducerModelConfig Transducer;
|
||||
public OfflineParaformerModelConfig Paraformer;
|
||||
public OfflineNemoEncDecCtcModelConfig NeMoCtc;
|
||||
public OfflineWhisperModelConfig Whisper;
|
||||
public OfflineTdnnModelConfig Tdnn;
|
||||
|
||||
[MarshalAs(UnmanagedType.LPStr)]
|
||||
public string Tokens;
|
||||
|
||||
@@ -309,6 +309,15 @@ type OfflineNemoEncDecCtcModelConfig struct {
|
||||
Model string // Path to the model, e.g., model.onnx or model.int8.onnx
|
||||
}
|
||||
|
||||
type OfflineWhisperModelConfig struct {
|
||||
Encoder string
|
||||
Decoder string
|
||||
}
|
||||
|
||||
type OfflineTdnnModelConfig struct {
|
||||
Model string
|
||||
}
|
||||
|
||||
// Configuration for offline LM.
|
||||
type OfflineLMConfig struct {
|
||||
Model string // Path to the model
|
||||
@@ -319,6 +328,8 @@ type OfflineModelConfig struct {
|
||||
Transducer OfflineTransducerModelConfig
|
||||
Paraformer OfflineParaformerModelConfig
|
||||
NemoCTC OfflineNemoEncDecCtcModelConfig
|
||||
Whisper OfflineWhisperModelConfig
|
||||
Tdnn OfflineTdnnModelConfig
|
||||
Tokens string // Path to tokens.txt
|
||||
|
||||
// Number of threads to use for neural network computation
|
||||
@@ -390,6 +401,15 @@ func NewOfflineRecognizer(config *OfflineRecognizerConfig) *OfflineRecognizer {
|
||||
c.model_config.nemo_ctc.model = C.CString(config.ModelConfig.NemoCTC.Model)
|
||||
defer C.free(unsafe.Pointer(c.model_config.nemo_ctc.model))
|
||||
|
||||
c.model_config.whisper.encoder = C.CString(config.ModelConfig.Whisper.Encoder)
|
||||
defer C.free(unsafe.Pointer(c.model_config.whisper.encoder))
|
||||
|
||||
c.model_config.whisper.decoder = C.CString(config.ModelConfig.Whisper.Decoder)
|
||||
defer C.free(unsafe.Pointer(c.model_config.whisper.decoder))
|
||||
|
||||
c.model_config.tdnn.decoder = C.CString(config.ModelConfig.Tdnn.Model)
|
||||
defer C.free(unsafe.Pointer(c.model_config.tdnn.model))
|
||||
|
||||
c.model_config.tokens = C.CString(config.ModelConfig.Tokens)
|
||||
defer C.free(unsafe.Pointer(c.model_config.tokens))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user