Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
xuning
/
sherpaonnx
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Fangjun Kuang
2025-01-25 22:23:12 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
GitHub
2025-01-25 22:23:12 +0800
Commit
73c3695287c682fee8675d3bb4b874854f80caf4
73c36952
1 parent
030aaa7b
Refactor node-addon C++ code. (#1768)
Use macros to delete pointers.
隐藏空白字符变更
内嵌
并排对比
正在显示
9 个修改的文件
包含
70 行增加
和
249 行删除
harmony-os/SherpaOnnxHar/sherpa_onnx/src/main/cpp/audio-tagging.cc
harmony-os/SherpaOnnxHar/sherpa_onnx/src/main/cpp/keyword-spotting.cc
harmony-os/SherpaOnnxHar/sherpa_onnx/src/main/cpp/non-streaming-speaker-diarization.cc
harmony-os/SherpaOnnxHar/sherpa_onnx/src/main/cpp/non-streaming-tts.cc
harmony-os/SherpaOnnxHar/sherpa_onnx/src/main/cpp/punctuation.cc
harmony-os/SherpaOnnxHar/sherpa_onnx/src/main/cpp/speaker-identification.cc
harmony-os/SherpaOnnxHar/sherpa_onnx/src/main/cpp/spoken-language-identification.cc
harmony-os/SherpaOnnxHar/sherpa_onnx/src/main/cpp/streaming-asr.cc
harmony-os/SherpaOnnxHar/sherpa_onnx/src/main/cpp/vad.cc
harmony-os/SherpaOnnxHar/sherpa_onnx/src/main/cpp/audio-tagging.cc
查看文件 @
73c3695
...
...
@@ -82,21 +82,10 @@ static Napi::External<SherpaOnnxAudioTagging> CreateAudioTaggingWrapper(
const
SherpaOnnxAudioTagging
*
at
=
SherpaOnnxCreateAudioTagging
(
&
c
);
if
(
c
.
model
.
zipformer
.
model
)
{
delete
[]
c
.
model
.
zipformer
.
model
;
}
if
(
c
.
model
.
ced
)
{
delete
[]
c
.
model
.
ced
;
}
if
(
c
.
model
.
provider
)
{
delete
[]
c
.
model
.
provider
;
}
if
(
c
.
labels
)
{
delete
[]
c
.
labels
;
}
SHERPA_ONNX_DELETE_C_STR
(
c
.
model
.
zipformer
.
model
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
model
.
ced
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
model
.
provider
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
labels
);
if
(
!
at
)
{
Napi
::
TypeError
::
New
(
env
,
"Please check your config!"
)
...
...
harmony-os/SherpaOnnxHar/sherpa_onnx/src/main/cpp/keyword-spotting.cc
查看文件 @
73c3695
...
...
@@ -47,50 +47,20 @@ static Napi::External<SherpaOnnxKeywordSpotter> CreateKeywordSpotterWrapper(
SHERPA_ONNX_ASSIGN_ATTR_INT32
(
keywords_buf_size
,
keywordsBufSize
);
const
SherpaOnnxKeywordSpotter
*
kws
=
SherpaOnnxCreateKeywordSpotter
(
&
c
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
model_config
.
transducer
.
encoder
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
model_config
.
transducer
.
decoder
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
model_config
.
transducer
.
joiner
);
if
(
c
.
model_config
.
transducer
.
encoder
)
{
delete
[]
c
.
model_config
.
transducer
.
encoder
;
}
if
(
c
.
model_config
.
transducer
.
decoder
)
{
delete
[]
c
.
model_config
.
transducer
.
decoder
;
}
if
(
c
.
model_config
.
transducer
.
joiner
)
{
delete
[]
c
.
model_config
.
transducer
.
joiner
;
}
SHERPA_ONNX_DELETE_C_STR
(
c
.
model_config
.
paraformer
.
encoder
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
model_config
.
paraformer
.
decoder
);
if
(
c
.
model_config
.
paraformer
.
encoder
)
{
delete
[]
c
.
model_config
.
paraformer
.
encoder
;
}
if
(
c
.
model_config
.
paraformer
.
decoder
)
{
delete
[]
c
.
model_config
.
paraformer
.
decoder
;
}
if
(
c
.
model_config
.
zipformer2_ctc
.
model
)
{
delete
[]
c
.
model_config
.
zipformer2_ctc
.
model
;
}
SHERPA_ONNX_DELETE_C_STR
(
c
.
model_config
.
zipformer2_ctc
.
model
);
if
(
c
.
model_config
.
tokens
)
{
delete
[]
c
.
model_config
.
tokens
;
}
if
(
c
.
model_config
.
provider
)
{
delete
[]
c
.
model_config
.
provider
;
}
if
(
c
.
model_config
.
model_type
)
{
delete
[]
c
.
model_config
.
model_type
;
}
if
(
c
.
keywords_file
)
{
delete
[]
c
.
keywords_file
;
}
if
(
c
.
keywords_buf
)
{
delete
[]
c
.
keywords_buf
;
}
SHERPA_ONNX_DELETE_C_STR
(
c
.
model_config
.
tokens
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
model_config
.
provider
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
model_config
.
model_type
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
keywords_file
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
keywords_buf
);
if
(
!
kws
)
{
Napi
::
TypeError
::
New
(
env
,
"Please check your config!"
)
...
...
harmony-os/SherpaOnnxHar/sherpa_onnx/src/main/cpp/non-streaming-speaker-diarization.cc
查看文件 @
73c3695
...
...
@@ -154,21 +154,10 @@ CreateOfflineSpeakerDiarizationWrapper(const Napi::CallbackInfo &info) {
SherpaOnnxCreateOfflineSpeakerDiarization
(
&
c
);
#endif
if
(
c
.
segmentation
.
pyannote
.
model
)
{
delete
[]
c
.
segmentation
.
pyannote
.
model
;
}
if
(
c
.
segmentation
.
provider
)
{
delete
[]
c
.
segmentation
.
provider
;
}
if
(
c
.
embedding
.
model
)
{
delete
[]
c
.
embedding
.
model
;
}
if
(
c
.
embedding
.
provider
)
{
delete
[]
c
.
embedding
.
provider
;
}
SHERPA_ONNX_DELETE_C_STR
(
c
.
segmentation
.
pyannote
.
model
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
segmentation
.
provider
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
embedding
.
model
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
embedding
.
provider
);
if
(
!
sd
)
{
Napi
::
TypeError
::
New
(
env
,
"Please check your config!"
)
...
...
harmony-os/SherpaOnnxHar/sherpa_onnx/src/main/cpp/non-streaming-tts.cc
查看文件 @
73c3695
...
...
@@ -155,78 +155,28 @@ static Napi::External<SherpaOnnxOfflineTts> CreateOfflineTtsWrapper(
#else
const
SherpaOnnxOfflineTts
*
tts
=
SherpaOnnxCreateOfflineTts
(
&
c
);
#endif
if
(
c
.
model
.
vits
.
model
)
{
delete
[]
c
.
model
.
vits
.
model
;
}
if
(
c
.
model
.
vits
.
lexicon
)
{
delete
[]
c
.
model
.
vits
.
lexicon
;
}
if
(
c
.
model
.
vits
.
tokens
)
{
delete
[]
c
.
model
.
vits
.
tokens
;
}
if
(
c
.
model
.
vits
.
data_dir
)
{
delete
[]
c
.
model
.
vits
.
data_dir
;
}
if
(
c
.
model
.
vits
.
dict_dir
)
{
delete
[]
c
.
model
.
vits
.
dict_dir
;
}
if
(
c
.
model
.
matcha
.
acoustic_model
)
{
delete
[]
c
.
model
.
matcha
.
acoustic_model
;
}
if
(
c
.
model
.
matcha
.
vocoder
)
{
delete
[]
c
.
model
.
matcha
.
vocoder
;
}
if
(
c
.
model
.
matcha
.
lexicon
)
{
delete
[]
c
.
model
.
matcha
.
lexicon
;
}
if
(
c
.
model
.
matcha
.
tokens
)
{
delete
[]
c
.
model
.
matcha
.
tokens
;
}
if
(
c
.
model
.
matcha
.
data_dir
)
{
delete
[]
c
.
model
.
matcha
.
data_dir
;
}
if
(
c
.
model
.
matcha
.
dict_dir
)
{
delete
[]
c
.
model
.
matcha
.
dict_dir
;
}
if
(
c
.
model
.
kokoro
.
model
)
{
delete
[]
c
.
model
.
kokoro
.
model
;
}
if
(
c
.
model
.
kokoro
.
voices
)
{
delete
[]
c
.
model
.
kokoro
.
voices
;
}
if
(
c
.
model
.
kokoro
.
tokens
)
{
delete
[]
c
.
model
.
kokoro
.
tokens
;
}
if
(
c
.
model
.
kokoro
.
data_dir
)
{
delete
[]
c
.
model
.
kokoro
.
data_dir
;
}
if
(
c
.
model
.
provider
)
{
delete
[]
c
.
model
.
provider
;
}
if
(
c
.
rule_fsts
)
{
delete
[]
c
.
rule_fsts
;
}
if
(
c
.
rule_fars
)
{
delete
[]
c
.
rule_fars
;
}
SHERPA_ONNX_DELETE_C_STR
(
c
.
model
.
vits
.
model
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
model
.
vits
.
lexicon
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
model
.
vits
.
tokens
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
model
.
vits
.
data_dir
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
model
.
vits
.
dict_dir
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
model
.
matcha
.
acoustic_model
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
model
.
matcha
.
vocoder
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
model
.
matcha
.
lexicon
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
model
.
matcha
.
tokens
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
model
.
matcha
.
data_dir
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
model
.
matcha
.
dict_dir
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
model
.
kokoro
.
model
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
model
.
kokoro
.
voices
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
model
.
kokoro
.
tokens
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
model
.
kokoro
.
data_dir
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
model
.
provider
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
rule_fsts
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
rule_fars
);
if
(
!
tts
)
{
Napi
::
TypeError
::
New
(
env
,
"Please check your config!"
)
...
...
harmony-os/SherpaOnnxHar/sherpa_onnx/src/main/cpp/punctuation.cc
查看文件 @
73c3695
...
...
@@ -63,13 +63,8 @@ CreateOfflinePunctuationWrapper(const Napi::CallbackInfo &info) {
const
SherpaOnnxOfflinePunctuation
*
punct
=
SherpaOnnxCreateOfflinePunctuation
(
&
c
);
if
(
c
.
model
.
ct_transformer
)
{
delete
[]
c
.
model
.
ct_transformer
;
}
if
(
c
.
model
.
provider
)
{
delete
[]
c
.
model
.
provider
;
}
SHERPA_ONNX_DELETE_C_STR
(
c
.
model
.
ct_transformer
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
model
.
provider
);
if
(
!
punct
)
{
Napi
::
TypeError
::
New
(
env
,
"Please check your config!"
)
...
...
harmony-os/SherpaOnnxHar/sherpa_onnx/src/main/cpp/speaker-identification.cc
查看文件 @
73c3695
...
...
@@ -70,14 +70,8 @@ CreateSpeakerEmbeddingExtractorWrapper(const Napi::CallbackInfo &info) {
const
SherpaOnnxSpeakerEmbeddingExtractor
*
extractor
=
SherpaOnnxCreateSpeakerEmbeddingExtractor
(
&
c
);
#endif
if
(
c
.
model
)
{
delete
[]
c
.
model
;
}
if
(
c
.
provider
)
{
delete
[]
c
.
provider
;
}
SHERPA_ONNX_DELETE_C_STR
(
c
.
model
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
provider
);
if
(
!
extractor
)
{
Napi
::
TypeError
::
New
(
env
,
"Please check your config!"
)
...
...
harmony-os/SherpaOnnxHar/sherpa_onnx/src/main/cpp/spoken-language-identification.cc
查看文件 @
73c3695
...
...
@@ -66,17 +66,9 @@ CreateSpokenLanguageIdentificationWrapper(const Napi::CallbackInfo &info) {
const
SherpaOnnxSpokenLanguageIdentification
*
slid
=
SherpaOnnxCreateSpokenLanguageIdentification
(
&
c
);
if
(
c
.
whisper
.
encoder
)
{
delete
[]
c
.
whisper
.
encoder
;
}
if
(
c
.
whisper
.
decoder
)
{
delete
[]
c
.
whisper
.
decoder
;
}
if
(
c
.
provider
)
{
delete
[]
c
.
provider
;
}
SHERPA_ONNX_DELETE_C_STR
(
c
.
whisper
.
encoder
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
whisper
.
decoder
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
provider
);
if
(
!
slid
)
{
Napi
::
TypeError
::
New
(
env
,
"Please check your config!"
)
...
...
harmony-os/SherpaOnnxHar/sherpa_onnx/src/main/cpp/streaming-asr.cc
查看文件 @
73c3695
...
...
@@ -222,78 +222,26 @@ static Napi::External<SherpaOnnxOnlineRecognizer> CreateOnlineRecognizerWrapper(
const
SherpaOnnxOnlineRecognizer
*
recognizer
=
SherpaOnnxCreateOnlineRecognizer
(
&
c
);
#endif
if
(
c
.
model_config
.
transducer
.
encoder
)
{
delete
[]
c
.
model_config
.
transducer
.
encoder
;
}
if
(
c
.
model_config
.
transducer
.
decoder
)
{
delete
[]
c
.
model_config
.
transducer
.
decoder
;
}
if
(
c
.
model_config
.
transducer
.
joiner
)
{
delete
[]
c
.
model_config
.
transducer
.
joiner
;
}
if
(
c
.
model_config
.
paraformer
.
encoder
)
{
delete
[]
c
.
model_config
.
paraformer
.
encoder
;
}
if
(
c
.
model_config
.
paraformer
.
decoder
)
{
delete
[]
c
.
model_config
.
paraformer
.
decoder
;
}
if
(
c
.
model_config
.
zipformer2_ctc
.
model
)
{
delete
[]
c
.
model_config
.
zipformer2_ctc
.
model
;
}
if
(
c
.
model_config
.
tokens
)
{
delete
[]
c
.
model_config
.
tokens
;
}
if
(
c
.
model_config
.
provider
)
{
delete
[]
c
.
model_config
.
provider
;
}
if
(
c
.
model_config
.
model_type
)
{
delete
[]
c
.
model_config
.
model_type
;
}
if
(
c
.
model_config
.
modeling_unit
)
{
delete
[]
c
.
model_config
.
modeling_unit
;
}
if
(
c
.
model_config
.
bpe_vocab
)
{
delete
[]
c
.
model_config
.
bpe_vocab
;
}
if
(
c
.
model_config
.
tokens_buf
)
{
delete
[]
c
.
model_config
.
tokens_buf
;
}
if
(
c
.
decoding_method
)
{
delete
[]
c
.
decoding_method
;
}
if
(
c
.
hotwords_file
)
{
delete
[]
c
.
hotwords_file
;
}
if
(
c
.
rule_fsts
)
{
delete
[]
c
.
rule_fsts
;
}
if
(
c
.
rule_fars
)
{
delete
[]
c
.
rule_fars
;
}
if
(
c
.
hotwords_buf
)
{
delete
[]
c
.
hotwords_buf
;
}
if
(
c
.
ctc_fst_decoder_config
.
graph
)
{
delete
[]
c
.
ctc_fst_decoder_config
.
graph
;
}
SHERPA_ONNX_DELETE_C_STR
(
c
.
model_config
.
transducer
.
encoder
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
model_config
.
transducer
.
decoder
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
model_config
.
transducer
.
joiner
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
model_config
.
paraformer
.
encoder
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
model_config
.
paraformer
.
decoder
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
model_config
.
zipformer2_ctc
.
model
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
model_config
.
tokens
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
model_config
.
provider
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
model_config
.
model_type
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
model_config
.
modeling_unit
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
model_config
.
bpe_vocab
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
model_config
.
tokens_buf
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
decoding_method
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
hotwords_file
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
rule_fsts
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
rule_fars
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
hotwords_buf
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
ctc_fst_decoder_config
.
graph
);
if
(
!
recognizer
)
{
Napi
::
TypeError
::
New
(
env
,
"Please check your config!"
)
...
...
harmony-os/SherpaOnnxHar/sherpa_onnx/src/main/cpp/vad.cc
查看文件 @
73c3695
...
...
@@ -367,14 +367,8 @@ CreateVoiceActivityDetectorWrapper(const Napi::CallbackInfo &info) {
SherpaOnnxVoiceActivityDetector
*
vad
=
SherpaOnnxCreateVoiceActivityDetector
(
&
c
,
buffer_size_in_seconds
);
#endif
if
(
c
.
silero_vad
.
model
)
{
delete
[]
c
.
silero_vad
.
model
;
}
if
(
c
.
provider
)
{
delete
[]
c
.
provider
;
}
SHERPA_ONNX_DELETE_C_STR
(
c
.
silero_vad
.
model
);
SHERPA_ONNX_DELETE_C_STR
(
c
.
provider
);
return
Napi
::
External
<
SherpaOnnxVoiceActivityDetector
>::
New
(
env
,
vad
,
[](
Napi
::
Env
env
,
SherpaOnnxVoiceActivityDetector
*
p
)
{
...
...
请
注册
或
登录
后发表评论