Fix -- bug

This commit is contained in:
litagin02
2024-02-02 22:27:58 +09:00
parent 631f72da39
commit 3d434fd4c8

View File

@@ -343,13 +343,14 @@ def text2sep_kata(norm_text: str) -> tuple[list[str], list[str]]:
""" """
assert yomi != "", f"Empty yomi: {word}" assert yomi != "", f"Empty yomi: {word}"
if yomi == "": if yomi == "":
# wordは正規化されているので、`.`, `,`, `!`, `'`, `-`のいずれか # wordは正規化されているので、`.`, `,`, `!`, `'`, `-`, `--` のいずれか
if word not in ( if word not in (
".", ".",
",", ",",
"!", "!",
"'", "'",
"-", "-",
"--",
): ):
# ここはpyopenjtalkが読めない文字等のときに起こる # ここはpyopenjtalkが読めない文字等のときに起こる
raise ValueError(f"Cannot read: {word} in:\n{norm_text}") raise ValueError(f"Cannot read: {word} in:\n{norm_text}")
@@ -547,6 +548,8 @@ def kata2phoneme_list(text: str) -> list[str]:
""" """
if text in punctuation: if text in punctuation:
return [text] return [text]
elif text == "--":
return ["-", "-"]
# `text`がカタカナ(`ー`含む)のみからなるかどうかをチェック # `text`がカタカナ(`ー`含む)のみからなるかどうかをチェック
if re.fullmatch(r"[\u30A0-\u30FF]+", text) is None: if re.fullmatch(r"[\u30A0-\u30FF]+", text) is None:
raise ValueError(f"Input must be katakana only: {text}") raise ValueError(f"Input must be katakana only: {text}")