Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gst-kaldi-nnet2-online
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
homeostasis
gst-kaldi-nnet2-online
Commits
bb3ac78d
Commit
bb3ac78d
authored
10 years ago
by
Tanel Alumäe
Browse files
Options
Downloads
Plain Diff
Merge pull request #2 from amitbeka/inverse-scale
Inverse scale
parents
a68ec533
c693149c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/gstkaldinnet2onlinedecoder.cc
+47
-1
47 additions, 1 deletion
src/gstkaldinnet2onlinedecoder.cc
src/gstkaldinnet2onlinedecoder.h
+2
-0
2 additions, 0 deletions
src/gstkaldinnet2onlinedecoder.h
with
49 additions
and
1 deletion
src/gstkaldinnet2onlinedecoder.cc
+
47
−
1
View file @
bb3ac78d
...
@@ -70,12 +70,15 @@ enum {
...
@@ -70,12 +70,15 @@ enum {
PROP_WORD_SYMS
,
PROP_WORD_SYMS
,
PROP_DO_ENDPOINTING
,
PROP_DO_ENDPOINTING
,
PROP_ADAPTATION_STATE
,
PROP_ADAPTATION_STATE
,
PROP_INVERSE_SCALE
,
PROP_LMWT_SCALE
,
PROP_LAST
PROP_LAST
};
};
#define DEFAULT_MODEL "final.mdl"
#define DEFAULT_MODEL "final.mdl"
#define DEFAULT_FST "HCLG.fst"
#define DEFAULT_FST "HCLG.fst"
#define DEFAULT_WORD_SYMS "words.txt"
#define DEFAULT_WORD_SYMS "words.txt"
#define DEFAULT_LMWT_SCALE 1.0
/* the capabilities of the inputs and outputs.
/* the capabilities of the inputs and outputs.
*
*
...
@@ -185,6 +188,26 @@ static void gst_kaldinnet2onlinedecoder_class_init(
...
@@ -185,6 +188,26 @@ static void gst_kaldinnet2onlinedecoder_class_init(
""
,
""
,
(
GParamFlags
)
G_PARAM_READWRITE
));
(
GParamFlags
)
G_PARAM_READWRITE
));
g_object_class_install_property
(
gobject_class
,
PROP_INVERSE_SCALE
,
g_param_spec_boolean
(
"inverse-scale"
,
"If true, inverse acoustic scale in lattice"
,
"If true, inverse the acoustic scaling of the output lattice"
,
FALSE
,
(
GParamFlags
)
G_PARAM_READWRITE
));
g_object_class_install_property
(
gobject_class
,
PROP_LMWT_SCALE
,
g_param_spec_float
(
"lmwt-scale"
,
"LM weight for scaling output lattice"
,
"LM scaling for the output lattice, usually in conjunction with inverse-scaling=true"
,
G_MINFLOAT
,
G_MAXFLOAT
,
DEFAULT_LMWT_SCALE
,
(
GParamFlags
)
G_PARAM_READWRITE
));
gst_kaldinnet2onlinedecoder_signals
[
PARTIAL_RESULT_SIGNAL
]
=
g_signal_new
(
gst_kaldinnet2onlinedecoder_signals
[
PARTIAL_RESULT_SIGNAL
]
=
g_signal_new
(
"partial-result"
,
G_TYPE_FROM_CLASS
(
klass
),
G_SIGNAL_RUN_LAST
,
"partial-result"
,
G_TYPE_FROM_CLASS
(
klass
),
G_SIGNAL_RUN_LAST
,
G_STRUCT_OFFSET
(
Gstkaldinnet2onlinedecoderClass
,
partial_result
),
G_STRUCT_OFFSET
(
Gstkaldinnet2onlinedecoderClass
,
partial_result
),
...
@@ -260,6 +283,8 @@ static void gst_kaldinnet2onlinedecoder_init(
...
@@ -260,6 +283,8 @@ static void gst_kaldinnet2onlinedecoder_init(
filter
->
feature_info
=
NULL
;
filter
->
feature_info
=
NULL
;
filter
->
sample_rate
=
0
;
filter
->
sample_rate
=
0
;
filter
->
decoding
=
false
;
filter
->
decoding
=
false
;
filter
->
lmwt_scale
=
DEFAULT_LMWT_SCALE
;
filter
->
inverse_scale
=
FALSE
;
// init properties from various Kaldi Opts
// init properties from various Kaldi Opts
GstElementClass
*
klass
=
GST_ELEMENT_GET_CLASS
(
filter
);
GstElementClass
*
klass
=
GST_ELEMENT_GET_CLASS
(
filter
);
...
@@ -366,6 +391,12 @@ static void gst_kaldinnet2onlinedecoder_set_property(GObject * object,
...
@@ -366,6 +391,12 @@ static void gst_kaldinnet2onlinedecoder_set_property(GObject * object,
case
PROP_DO_ENDPOINTING
:
case
PROP_DO_ENDPOINTING
:
filter
->
do_endpointing
=
g_value_get_boolean
(
value
);
filter
->
do_endpointing
=
g_value_get_boolean
(
value
);
break
;
break
;
case
PROP_INVERSE_SCALE
:
filter
->
inverse_scale
=
g_value_get_boolean
(
value
);
break
;
case
PROP_LMWT_SCALE
:
filter
->
lmwt_scale
=
g_value_get_float
(
value
);
break
;
case
PROP_ADAPTATION_STATE
:
case
PROP_ADAPTATION_STATE
:
{
{
if
(
G_VALUE_HOLDS_STRING
(
value
))
{
if
(
G_VALUE_HOLDS_STRING
(
value
))
{
...
@@ -463,6 +494,12 @@ static void gst_kaldinnet2onlinedecoder_get_property(GObject * object,
...
@@ -463,6 +494,12 @@ static void gst_kaldinnet2onlinedecoder_get_property(GObject * object,
case
PROP_DO_ENDPOINTING
:
case
PROP_DO_ENDPOINTING
:
g_value_set_boolean
(
value
,
filter
->
do_endpointing
);
g_value_set_boolean
(
value
,
filter
->
do_endpointing
);
break
;
break
;
case
PROP_INVERSE_SCALE
:
g_value_set_boolean
(
value
,
filter
->
inverse_scale
);
break
;
case
PROP_LMWT_SCALE
:
g_value_set_float
(
value
,
filter
->
lmwt_scale
);
break
;
case
PROP_ADAPTATION_STATE
:
case
PROP_ADAPTATION_STATE
:
string_stream
.
clear
();
string_stream
.
clear
();
if
(
filter
->
adaptation_state
)
{
if
(
filter
->
adaptation_state
)
{
...
@@ -513,13 +550,22 @@ static void gst_kaldinnet2onlinedecoder_get_property(GObject * object,
...
@@ -513,13 +550,22 @@ static void gst_kaldinnet2onlinedecoder_get_property(GObject * object,
}
}
static
void
gst_kaldinnet2onlinedecoder_final_result
(
static
void
gst_kaldinnet2onlinedecoder_final_result
(
Gstkaldinnet2onlinedecoder
*
filter
,
const
CompactLattice
&
clat
,
Gstkaldinnet2onlinedecoder
*
filter
,
CompactLattice
&
clat
,
int64
*
tot_num_frames
,
double
*
tot_like
,
guint
*
num_words
)
{
int64
*
tot_num_frames
,
double
*
tot_like
,
guint
*
num_words
)
{
if
(
clat
.
NumStates
()
==
0
)
{
if
(
clat
.
NumStates
()
==
0
)
{
KALDI_WARN
<<
"Empty lattice."
;
KALDI_WARN
<<
"Empty lattice."
;
return
;
return
;
}
}
CompactLattice
best_path_clat
;
CompactLattice
best_path_clat
;
if
(
filter
->
inverse_scale
)
{
BaseFloat
inv_acoustic_scale
=
1.0
/
filter
->
nnet2_decoding_config
->
decodable_opts
.
acoustic_scale
;
fst
::
ScaleLattice
(
fst
::
AcousticLatticeScale
(
inv_acoustic_scale
),
&
clat
);
}
fst
::
ScaleLattice
(
fst
::
LatticeScale
(
filter
->
lmwt_scale
,
1.0
),
&
clat
);
CompactLatticeShortestPath
(
clat
,
&
best_path_clat
);
CompactLatticeShortestPath
(
clat
,
&
best_path_clat
);
Lattice
best_path_lat
;
Lattice
best_path_lat
;
...
...
This diff is collapsed.
Click to expand it.
src/gstkaldinnet2onlinedecoder.h
+
2
−
0
View file @
bb3ac78d
...
@@ -60,6 +60,8 @@ struct _Gstkaldinnet2onlinedecoder {
...
@@ -60,6 +60,8 @@ struct _Gstkaldinnet2onlinedecoder {
gboolean
silent
;
gboolean
silent
;
gboolean
do_endpointing
;
gboolean
do_endpointing
;
gboolean
inverse_scale
;
float
lmwt_scale
;
GstBufferSource
*
audio_source
;
GstBufferSource
*
audio_source
;
gchar
*
model_rspecifier
;
gchar
*
model_rspecifier
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment