Skip to content

Commit 6371b08

Browse files
committed
Move get_builder below __init__, set proper typing
1 parent 9d3177a commit 6371b08

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

i6_models/parts/rasr_fsa.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import numpy as np
1010
import torch
1111

12+
1213
if TYPE_CHECKING:
1314
import librasr
1415

@@ -117,13 +118,6 @@ class _AbstractRasrFsaBuilder(ABC):
117118
This is necessary for pickling as the C++ class `librasr.AllophoneStateFsaBuilder` is not picklable.
118119
"""
119120

120-
def get_builder(self, config_path: str) -> "librasr.AllophoneStateFsaBuilder":
121-
import librasr
122-
123-
config = librasr.Configuration()
124-
config.set_from_file(config_path)
125-
return librasr.AllophoneStateFsaBuilder(config)
126-
127121
def __init__(self, config_path: str, tdp_scale: float = 1.0):
128122
"""
129123
:param config_path: Path to the RASR FSA exporter config. The FSA builder will be created from here.
@@ -133,6 +127,13 @@ def __init__(self, config_path: str, tdp_scale: float = 1.0):
133127
self.builder = self.get_builder(config_path=self.config_path)
134128
self.tdp_scale = tdp_scale
135129

130+
def get_builder(self, config_path: str) -> librasr.AllophoneStateFsaBuilder:
131+
import librasr
132+
133+
config = librasr.Configuration()
134+
config.set_from_file(config_path)
135+
return librasr.AllophoneStateFsaBuilder(config)
136+
136137
def __getstate__(self):
137138
state = self.__dict__.copy()
138139
del state["builder"]

0 commit comments

Comments
 (0)