Inverse text normalization API for other programming languages (#1019)
This commit is contained in:
@@ -21,7 +21,8 @@ namespace SherpaOnnx
|
||||
MaxActivePaths = 4;
|
||||
HotwordsFile = "";
|
||||
HotwordsScore = 1.5F;
|
||||
|
||||
RuleFsts = "";
|
||||
RuleFars = "";
|
||||
}
|
||||
public FeatureConfig FeatConfig;
|
||||
public OfflineModelConfig ModelConfig;
|
||||
@@ -36,5 +37,11 @@ namespace SherpaOnnx
|
||||
public string HotwordsFile;
|
||||
|
||||
public float HotwordsScore;
|
||||
|
||||
[MarshalAs(UnmanagedType.LPStr)]
|
||||
public string RuleFsts;
|
||||
|
||||
[MarshalAs(UnmanagedType.LPStr)]
|
||||
public string RuleFars;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../../../go-api-examples/non-streaming-decode-files/run-paraformer-itn.sh
|
||||
@@ -397,6 +397,10 @@ type OfflineRecognizerConfig struct {
|
||||
|
||||
// Used only when DecodingMethod is modified_beam_search.
|
||||
MaxActivePaths int
|
||||
HotwordsFile string
|
||||
HotwordsScore float32
|
||||
RuleFsts string
|
||||
RuleFars string
|
||||
}
|
||||
|
||||
// It wraps a pointer from C
|
||||
@@ -491,6 +495,17 @@ func NewOfflineRecognizer(config *OfflineRecognizerConfig) *OfflineRecognizer {
|
||||
|
||||
c.max_active_paths = C.int(config.MaxActivePaths)
|
||||
|
||||
c.hotwords_file = C.CString(config.HotwordsFile)
|
||||
defer C.free(unsafe.Pointer(c.hotwords_file))
|
||||
|
||||
c.hotwords_score = C.float(config.HotwordsScore)
|
||||
|
||||
c.rule_fsts = C.CString(config.RuleFsts)
|
||||
defer C.free(unsafe.Pointer(c.rule_fsts))
|
||||
|
||||
c.rule_fars = C.CString(config.RuleFars)
|
||||
defer C.free(unsafe.Pointer(c.rule_fars))
|
||||
|
||||
recognizer := &OfflineRecognizer{}
|
||||
recognizer.impl = C.CreateOfflineRecognizer(&c)
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ cmake -DCMAKE_INSTALL_PREFIX=./install -DBUILD_SHARED_LIBS=ON ..
|
||||
make -j install
|
||||
export PKG_CONFIG_PATH=$PWD/install:$PKG_CONFIG_PATH
|
||||
cd ../scripts/node-addon-api/
|
||||
|
||||
./node_modules/.bin/node-gyp build --verbose
|
||||
npm i
|
||||
./node_modules/.bin/cmake-js compile --log-level verbose
|
||||
|
||||
# see test/test_asr_streaming_transducer.js
|
||||
# for usages
|
||||
|
||||
@@ -180,6 +180,8 @@ CreateOfflineRecognizerWrapper(const Napi::CallbackInfo &info) {
|
||||
SHERPA_ONNX_ASSIGN_ATTR_INT32(max_active_paths, maxActivePaths);
|
||||
SHERPA_ONNX_ASSIGN_ATTR_STR(hotwords_file, hotwordsFile);
|
||||
SHERPA_ONNX_ASSIGN_ATTR_FLOAT(hotwords_score, hotwordsScore);
|
||||
SHERPA_ONNX_ASSIGN_ATTR_STR(rule_fsts, ruleFsts);
|
||||
SHERPA_ONNX_ASSIGN_ATTR_STR(rule_fars, ruleFars);
|
||||
|
||||
SherpaOnnxOfflineRecognizer *recognizer = CreateOfflineRecognizer(&c);
|
||||
|
||||
@@ -259,6 +261,14 @@ CreateOfflineRecognizerWrapper(const Napi::CallbackInfo &info) {
|
||||
delete[] c.hotwords_file;
|
||||
}
|
||||
|
||||
if (c.rule_fsts) {
|
||||
delete[] c.rule_fsts;
|
||||
}
|
||||
|
||||
if (c.rule_fars) {
|
||||
delete[] c.rule_fars;
|
||||
}
|
||||
|
||||
if (!recognizer) {
|
||||
Napi::TypeError::New(env, "Please check your config!")
|
||||
.ThrowAsJavaScriptException();
|
||||
|
||||
@@ -44,7 +44,7 @@ static SherpaOnnxOfflineTtsModelConfig GetOfflineTtsModelConfig(
|
||||
|
||||
c.vits = GetOfflineTtsVitsModelConfig(o);
|
||||
|
||||
SHERPA_ONNX_ASSIGN_ATTR_INT32(num_threads, num_threads);
|
||||
SHERPA_ONNX_ASSIGN_ATTR_INT32(num_threads, numThreads);
|
||||
|
||||
if (o.Has("debug") &&
|
||||
(o.Get("debug").IsNumber() || o.Get("debug").IsBoolean())) {
|
||||
|
||||
Reference in New Issue
Block a user