From 28ccfbfc51068a663a80764e14074df5edf2b5ba Mon Sep 17 00:00:00 2001
From: kongdeqiang <kongdeqiang960204@163.com>
Date: 星期五, 13 三月 2026 17:41:41 +0800
Subject: [PATCH] 提交
---
fun_text_processing/text_normalization/de/verbalizers/verbalize_final.py | 26 ++++++++------------------
1 files changed, 8 insertions(+), 18 deletions(-)
diff --git a/fun_text_processing/text_normalization/de/verbalizers/verbalize_final.py b/fun_text_processing/text_normalization/de/verbalizers/verbalize_final.py
index e4d2adc..810a1c0 100644
--- a/fun_text_processing/text_normalization/de/verbalizers/verbalize_final.py
+++ b/fun_text_processing/text_normalization/de/verbalizers/verbalize_final.py
@@ -1,17 +1,3 @@
-# Copyright NeMo (https://github.com/NVIDIA/NeMo). All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
import os
import pynini
@@ -31,7 +17,7 @@
class VerbalizeFinalFst(GraphFst):
"""
Finite state transducer that verbalizes an entire sentence
-
+
Args:
deterministic: if True will provide a single transduction option,
for False multiple options (used for audio-based normalization)
@@ -39,16 +25,20 @@
overwrite_cache: set to True to overwrite .far files
"""
- def __init__(self, deterministic: bool = True, cache_dir: str = None, overwrite_cache: bool = False):
+ def __init__(
+ self, deterministic: bool = True, cache_dir: str = None, overwrite_cache: bool = False
+ ):
super().__init__(name="verbalize_final", kind="verbalize", deterministic=deterministic)
far_file = None
if cache_dir is not None and cache_dir != "None":
os.makedirs(cache_dir, exist_ok=True)
- far_file = os.path.join(cache_dir, f"de_tn_{deterministic}_deterministic_verbalizer.far")
+ far_file = os.path.join(
+ cache_dir, f"de_tn_{deterministic}_deterministic_verbalizer.far"
+ )
if not overwrite_cache and far_file and os.path.exists(far_file):
self.fst = pynini.Far(far_file, mode="r")["verbalize"]
- logging.info(f'VerbalizeFinalFst graph was restored from {far_file}.')
+ logging.info(f"VerbalizeFinalFst graph was restored from {far_file}.")
else:
verbalize = VerbalizeFst(deterministic=deterministic).fst
word = WordFst(deterministic=deterministic).fst
--
Gitblit v1.9.1