Fangjun Kuang
Committed by GitHub

Add C# API for homophone replacer (#2165)

  1 +/// Copyright (c) 2025 Xiaomi Corporation (authors: Fangjun Kuang)
  2 +
  3 +using System.Runtime.InteropServices;
  4 +
  5 +namespace SherpaOnnx
  6 +{
  7 + [StructLayout(LayoutKind.Sequential)]
  8 + public struct HomophoneReplacerConfig
  9 + {
  10 + public HomophoneReplacerConfig()
  11 + {
  12 + DictDir = "";
  13 + Lexicon = "";
  14 + RuleFsts = "";
  15 + }
  16 +
  17 + [MarshalAs(UnmanagedType.LPStr)]
  18 + public string DictDir;
  19 +
  20 + [MarshalAs(UnmanagedType.LPStr)]
  21 + public string Lexicon;
  22 +
  23 + [MarshalAs(UnmanagedType.LPStr)]
  24 + public string RuleFsts;
  25 + }
  26 +}
@@ -20,6 +20,7 @@ namespace SherpaOnnx @@ -20,6 +20,7 @@ namespace SherpaOnnx
20 RuleFsts = ""; 20 RuleFsts = "";
21 RuleFars = ""; 21 RuleFars = "";
22 BlankPenalty = 0.0F; 22 BlankPenalty = 0.0F;
  23 + Hr = new HomophoneReplacerConfig();
23 } 24 }
24 public FeatureConfig FeatConfig; 25 public FeatureConfig FeatConfig;
25 public OfflineModelConfig ModelConfig; 26 public OfflineModelConfig ModelConfig;
@@ -42,5 +43,7 @@ namespace SherpaOnnx @@ -42,5 +43,7 @@ namespace SherpaOnnx
42 public string RuleFars; 43 public string RuleFars;
43 44
44 public float BlankPenalty; 45 public float BlankPenalty;
  46 +
  47 + public HomophoneReplacerConfig Hr;
45 } 48 }
46 } 49 }
@@ -28,6 +28,7 @@ namespace SherpaOnnx @@ -28,6 +28,7 @@ namespace SherpaOnnx
28 BlankPenalty = 0.0F; 28 BlankPenalty = 0.0F;
29 HotwordsBuf = ""; 29 HotwordsBuf = "";
30 HotwordsBufSize = 0; 30 HotwordsBufSize = 0;
  31 + Hr = new HomophoneReplacerConfig();
31 } 32 }
32 public FeatureConfig FeatConfig; 33 public FeatureConfig FeatConfig;
33 public OnlineModelConfig ModelConfig; 34 public OnlineModelConfig ModelConfig;
@@ -79,5 +80,7 @@ namespace SherpaOnnx @@ -79,5 +80,7 @@ namespace SherpaOnnx
79 public string HotwordsBuf; 80 public string HotwordsBuf;
80 81
81 public int HotwordsBufSize; 82 public int HotwordsBufSize;
  83 +
  84 + public HomophoneReplacerConfig Hr;
82 } 85 }
83 } 86 }