Spaces:
Running
on
Zero
Running
on
Zero
Change to g2p_en
Browse files- inference_cli.py +10 -8
- utils/phonemize.py +2 -4
inference_cli.py
CHANGED
|
@@ -2,6 +2,7 @@
|
|
| 2 |
|
| 3 |
from typing import Any, Callable
|
| 4 |
import json
|
|
|
|
| 5 |
|
| 6 |
import fire
|
| 7 |
import torch
|
|
@@ -146,18 +147,19 @@ class InferenceCLI:
|
|
| 146 |
output_path: str = "./output.wav",
|
| 147 |
):
|
| 148 |
|
| 149 |
-
from
|
|
|
|
| 150 |
|
| 151 |
self.init_speaker_model()
|
| 152 |
|
| 153 |
if not self.g2p:
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
self.g2p
|
| 161 |
|
| 162 |
if not self.word2phone:
|
| 163 |
self.word2phone = json.load(
|
|
|
|
| 2 |
|
| 3 |
from typing import Any, Callable
|
| 4 |
import json
|
| 5 |
+
import os
|
| 6 |
|
| 7 |
import fire
|
| 8 |
import torch
|
|
|
|
| 147 |
output_path: str = "./output.wav",
|
| 148 |
):
|
| 149 |
|
| 150 |
+
from g2p_en import G2p
|
| 151 |
+
import nltk
|
| 152 |
|
| 153 |
self.init_speaker_model()
|
| 154 |
|
| 155 |
if not self.g2p:
|
| 156 |
+
if not os.path.exists(
|
| 157 |
+
os.path.expanduser(
|
| 158 |
+
"~/nltk_data/taggers/averaged_perceptron_tagger_eng"
|
| 159 |
+
)
|
| 160 |
+
):
|
| 161 |
+
nltk.download("averaged_perceptron_tagger_eng")
|
| 162 |
+
self.g2p = G2p()
|
| 163 |
|
| 164 |
if not self.word2phone:
|
| 165 |
self.word2phone = json.load(
|
utils/phonemize.py
CHANGED
|
@@ -4,12 +4,10 @@ import re
|
|
| 4 |
def g2p_resolve(word, g2p_model):
|
| 5 |
"""Call G2P to generate pronunciation (used for handling OOV words)."""
|
| 6 |
try:
|
| 7 |
-
result = g2p_model
|
| 8 |
-
|
| 9 |
-
return result[0][0].split()
|
| 10 |
except Exception:
|
| 11 |
return None
|
| 12 |
-
return None
|
| 13 |
|
| 14 |
|
| 15 |
def text_norm(s):
|
|
|
|
| 4 |
def g2p_resolve(word, g2p_model):
|
| 5 |
"""Call G2P to generate pronunciation (used for handling OOV words)."""
|
| 6 |
try:
|
| 7 |
+
result = g2p_model(word)
|
| 8 |
+
return result
|
|
|
|
| 9 |
except Exception:
|
| 10 |
return None
|
|
|
|
| 11 |
|
| 12 |
|
| 13 |
def text_norm(s):
|