Skip to content

Commit

Permalink
Fix bug in lexicon compiler (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmcauliffe committed Mar 5, 2024
1 parent 7dc5e14 commit ac29bcf
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
13 changes: 4 additions & 9 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,7 @@
# autodoc_typehints_description_target = 'documented'
# autoclass_content = 'both'
autodoc_docstring_signature = True
autodoc_type_aliases = {
}
autodoc_type_aliases = {}

napoleon_preprocess_types = False
napoleon_attr_annotations = False
Expand Down Expand Up @@ -245,7 +244,7 @@
# The reST default role (used for this markup: `text`) to use for all
# documents.
#
default_role = "autolink"
default_role = "code"

# If true, '()' will be appended to :func: etc. cross-reference text.
#
Expand All @@ -262,9 +261,7 @@
# show_authors = False

# nitpicky = True
nitpick_ignore = [

]
nitpick_ignore = []

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = "sphinx"
Expand Down Expand Up @@ -512,9 +509,7 @@
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [

]
texinfo_documents = []

# Documents to append as an appendix to all manuals.
#
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies:
- kaldi=*=*cpu*
- scipy
- pynini
- openfst
- openfst=1.8.3
- setuptools_scm
- pybind11
- pytest
Expand Down
1 change: 1 addition & 0 deletions extensions/feat/feat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ void feat_feat_functions(py::module& m){
left_context,
right_context,
&output_features);
py::gil_scoped_acquire acquire;
return output_features;

},
Expand Down
4 changes: 2 additions & 2 deletions kalpy/feat/mfcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def __init__(
sample_frequency: float = 16000,
frame_length: int = 25,
frame_shift: int = 10,
dither: float = 1.0,
dither: float = 0.0,
preemphasis_coefficient: float = 0.97,
remove_dc_offset: bool = True,
window_type: str = "povey",
Expand All @@ -97,7 +97,7 @@ def __init__(
vtln_high: float = -500,
num_coefficients: int = 13,
use_energy: bool = True,
energy_floor: float = 0.0,
energy_floor: float = 1.0,
raw_energy: bool = True,
cepstral_lifter: float = 22.0,
htk_compatibility: bool = False,
Expand Down
28 changes: 16 additions & 12 deletions kalpy/fstext/lexicon.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ class Pronunciation:

orthography: str
pronunciation: str
probability: typing.Optional[float]
silence_after_probability: typing.Optional[float]
silence_before_correction: typing.Optional[float]
non_silence_before_correction: typing.Optional[float]
disambiguation: typing.Optional[int]
probability: typing.Optional[float] = None
silence_after_probability: typing.Optional[float] = None
silence_before_correction: typing.Optional[float] = None
non_silence_before_correction: typing.Optional[float] = None
disambiguation: typing.Optional[int] = None


def parse_dictionary_file(
Expand Down Expand Up @@ -192,10 +192,9 @@ def __init__(
self._align_lexicon = None
self.word_begin_label = word_begin_label
self.word_end_label = word_end_label
self.start_state = None
self.loop_state = None
self.silence_state = None
self.non_silence_state = None
self.start_state = 0
self.non_silence_state = 1
self.silence_state = 2

def clear(self):
self.pronunciations = []
Expand Down Expand Up @@ -364,12 +363,17 @@ def create_fsts(self, phonological_rule_fst: pynini.Fst = None):
self.word_table.find(self.silence_word)
self._fst = pynini.Fst()
self._align_fst = pynini.Fst()
self.start_state = self._fst.add_state()
# Start state = 0
self._fst.add_state()
self._align_fst.add_state()
self._fst.set_start(self.start_state)
self.non_silence_state = self._fst.add_state() # Also loop state

# Non silence state = 1
self._fst.add_state() # Also loop state
self._align_fst.add_state()
self.silence_state = self._fst.add_state()

# Silence state = 2
self._fst.add_state()
self._align_fst.add_state()

self._align_fst.set_start(self.start_state)
Expand Down

0 comments on commit ac29bcf

Please sign in to comment.