Add C# API for homophone replacer (#2165)
This commit is contained in:
26
scripts/dotnet/HomophoneReplacerConfig.cs
Normal file
26
scripts/dotnet/HomophoneReplacerConfig.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
/// Copyright (c) 2025 Xiaomi Corporation (authors: Fangjun Kuang)
|
||||||
|
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace SherpaOnnx
|
||||||
|
{
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct HomophoneReplacerConfig
|
||||||
|
{
|
||||||
|
public HomophoneReplacerConfig()
|
||||||
|
{
|
||||||
|
DictDir = "";
|
||||||
|
Lexicon = "";
|
||||||
|
RuleFsts = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
[MarshalAs(UnmanagedType.LPStr)]
|
||||||
|
public string DictDir;
|
||||||
|
|
||||||
|
[MarshalAs(UnmanagedType.LPStr)]
|
||||||
|
public string Lexicon;
|
||||||
|
|
||||||
|
[MarshalAs(UnmanagedType.LPStr)]
|
||||||
|
public string RuleFsts;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,6 +20,7 @@ namespace SherpaOnnx
|
|||||||
RuleFsts = "";
|
RuleFsts = "";
|
||||||
RuleFars = "";
|
RuleFars = "";
|
||||||
BlankPenalty = 0.0F;
|
BlankPenalty = 0.0F;
|
||||||
|
Hr = new HomophoneReplacerConfig();
|
||||||
}
|
}
|
||||||
public FeatureConfig FeatConfig;
|
public FeatureConfig FeatConfig;
|
||||||
public OfflineModelConfig ModelConfig;
|
public OfflineModelConfig ModelConfig;
|
||||||
@@ -42,5 +43,7 @@ namespace SherpaOnnx
|
|||||||
public string RuleFars;
|
public string RuleFars;
|
||||||
|
|
||||||
public float BlankPenalty;
|
public float BlankPenalty;
|
||||||
|
|
||||||
|
public HomophoneReplacerConfig Hr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ namespace SherpaOnnx
|
|||||||
BlankPenalty = 0.0F;
|
BlankPenalty = 0.0F;
|
||||||
HotwordsBuf = "";
|
HotwordsBuf = "";
|
||||||
HotwordsBufSize = 0;
|
HotwordsBufSize = 0;
|
||||||
|
Hr = new HomophoneReplacerConfig();
|
||||||
}
|
}
|
||||||
public FeatureConfig FeatConfig;
|
public FeatureConfig FeatConfig;
|
||||||
public OnlineModelConfig ModelConfig;
|
public OnlineModelConfig ModelConfig;
|
||||||
@@ -79,5 +80,7 @@ namespace SherpaOnnx
|
|||||||
public string HotwordsBuf;
|
public string HotwordsBuf;
|
||||||
|
|
||||||
public int HotwordsBufSize;
|
public int HotwordsBufSize;
|
||||||
|
|
||||||
|
public HomophoneReplacerConfig Hr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user