Add homonphone replacer example for Python API. (#2161)

This commit is contained in:
Fangjun Kuang
2025-04-29 15:59:34 +08:00
committed by GitHub
parent 73dba27145
commit 51f8824219
7 changed files with 133 additions and 2 deletions

View File

@@ -123,6 +123,27 @@ def get_args():
""",
)
parser.add_argument(
"--hr-dict-dir",
type=str,
default="",
help="If not empty, it is the jieba dict directory for homophone replacer",
)
parser.add_argument(
"--hr-lexicon",
type=str,
default="",
help="If not empty, it is the lexicon.txt for homophone replacer",
)
parser.add_argument(
"--hr-rule-fsts",
type=str,
default="",
help="If not empty, it is the replace.fst for homophone replacer",
)
return parser.parse_args()
@@ -148,6 +169,9 @@ def create_recognizer(args):
hotwords_file=args.hotwords_file,
hotwords_score=args.hotwords_score,
blank_penalty=args.blank_penalty,
hr_dict_dir=args.hr_dict_dir,
hr_rule_fsts=args.hr_rule_fsts,
hr_lexicon=args.hr_lexicon,
)
return recognizer