Spaces:
Runtime error
Runtime error
feature: add more param
Browse files- .gitattributes +16 -14
- app.py +24 -8
- data/wavernn.pt +3 -0
- requirements.txt +1 -2
.gitattributes
CHANGED
|
@@ -1,14 +1,16 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
| 1 |
+
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.tar.gz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
app.py
CHANGED
|
@@ -12,7 +12,7 @@ mockingbird = MockingBird()
|
|
| 12 |
mockingbird_path = Path(os.path.dirname(__file__)) / "data"
|
| 13 |
base_url = "https://al.smoe.top/d/Home/source/mockingbird/"
|
| 14 |
|
| 15 |
-
for sy in ["encoder.pt", "g_hifigan.pt"]:
|
| 16 |
if not os.path.exists(os.path.join(mockingbird_path, sy)):
|
| 17 |
torch.hub.download_url_to_file(f"{base_url}/{sy}", mockingbird_path / sy)
|
| 18 |
|
|
@@ -28,21 +28,28 @@ for model in ["azusa", "nanmei", "ltyai", "tianyi"]:
|
|
| 28 |
mockingbird.load_model(
|
| 29 |
Path(os.path.join(mockingbird_path, "encoder.pt")),
|
| 30 |
Path(os.path.join(mockingbird_path, "g_hifigan.pt")),
|
| 31 |
-
|
| 32 |
)
|
| 33 |
|
| 34 |
|
| 35 |
-
def inference(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
model_path = mockingbird_path / model_name
|
| 37 |
mockingbird.set_synthesizer(Path(os.path.join(model_path, f"{model_name}.pt")))
|
| 38 |
fd = NamedTemporaryFile(suffix=".wav", delete=False)
|
| 39 |
record = mockingbird.synthesize(
|
| 40 |
text=str(text),
|
| 41 |
input_wav=model_path / "record.wav",
|
| 42 |
-
vocoder_type=
|
| 43 |
-
style_idx=
|
| 44 |
-
min_stop_token=
|
| 45 |
-
steps=
|
| 46 |
)
|
| 47 |
with open(fd.name, "wb") as file:
|
| 48 |
file.write(record.getvalue())
|
|
@@ -60,11 +67,20 @@ gr.Interface(
|
|
| 60 |
gr.Radio(
|
| 61 |
["azusa", "nanmei", "ltyai", "tianyi"],
|
| 62 |
label="model type",
|
|
|
|
| 63 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
],
|
| 65 |
gr.Audio(type="filepath", label="Output"),
|
| 66 |
title=title,
|
| 67 |
description=description,
|
| 68 |
article=article,
|
| 69 |
-
examples=[["阿梓不是你的电子播放器", "azusa"], ["不是", "nanmei"]],
|
| 70 |
).launch()
|
|
|
|
| 12 |
mockingbird_path = Path(os.path.dirname(__file__)) / "data"
|
| 13 |
base_url = "https://al.smoe.top/d/Home/source/mockingbird/"
|
| 14 |
|
| 15 |
+
for sy in ["encoder.pt", "g_hifigan.pt", "wavernn.pt"]:
|
| 16 |
if not os.path.exists(os.path.join(mockingbird_path, sy)):
|
| 17 |
torch.hub.download_url_to_file(f"{base_url}/{sy}", mockingbird_path / sy)
|
| 18 |
|
|
|
|
| 28 |
mockingbird.load_model(
|
| 29 |
Path(os.path.join(mockingbird_path, "encoder.pt")),
|
| 30 |
Path(os.path.join(mockingbird_path, "g_hifigan.pt")),
|
| 31 |
+
Path(os.path.join(mockingbird_path, "wavernn.pt")),
|
| 32 |
)
|
| 33 |
|
| 34 |
|
| 35 |
+
def inference(
|
| 36 |
+
text: str,
|
| 37 |
+
model_name: str,
|
| 38 |
+
vocoder_type: str = "HifiGan",
|
| 39 |
+
style_idx: int = 0,
|
| 40 |
+
min_stop_token: int = 9,
|
| 41 |
+
steps: int = 2000,
|
| 42 |
+
):
|
| 43 |
model_path = mockingbird_path / model_name
|
| 44 |
mockingbird.set_synthesizer(Path(os.path.join(model_path, f"{model_name}.pt")))
|
| 45 |
fd = NamedTemporaryFile(suffix=".wav", delete=False)
|
| 46 |
record = mockingbird.synthesize(
|
| 47 |
text=str(text),
|
| 48 |
input_wav=model_path / "record.wav",
|
| 49 |
+
vocoder_type=vocoder_type,
|
| 50 |
+
style_idx=style_idx,
|
| 51 |
+
min_stop_token=min_stop_token,
|
| 52 |
+
steps=steps,
|
| 53 |
)
|
| 54 |
with open(fd.name, "wb") as file:
|
| 55 |
file.write(record.getvalue())
|
|
|
|
| 67 |
gr.Radio(
|
| 68 |
["azusa", "nanmei", "ltyai", "tianyi"],
|
| 69 |
label="model type",
|
| 70 |
+
value="azusa",
|
| 71 |
),
|
| 72 |
+
gr.Radio(
|
| 73 |
+
["HifiGan", "WaveRNN"],
|
| 74 |
+
label="Vocoder type",
|
| 75 |
+
value="HifiGan",
|
| 76 |
+
),
|
| 77 |
+
gr.Slider(minimum=-1, maximum=9, step=1, label="style idx", value=0),
|
| 78 |
+
gr.Slider(minimum=3, maximum=9, label="min stop token", value=9),
|
| 79 |
+
gr.Slider(minimum=200, maximum=2000, label="steps", value=2000),
|
| 80 |
],
|
| 81 |
gr.Audio(type="filepath", label="Output"),
|
| 82 |
title=title,
|
| 83 |
description=description,
|
| 84 |
article=article,
|
| 85 |
+
examples=[["阿梓不是你的电子播放器", "azusa", "HifiGan", 0, 9, 2000], ["不是", "nanmei", "HifiGan", 0, 9, 2000]],
|
| 86 |
).launch()
|
data/wavernn.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1d7a6861589e927e0fbdaa5849ca022258fe2b58a20cc7bfb8fb598ccf936169
|
| 3 |
+
size 53845290
|
requirements.txt
CHANGED
|
@@ -10,5 +10,4 @@ webrtcvad
|
|
| 10 |
Unidecode
|
| 11 |
inflect
|
| 12 |
loguru
|
| 13 |
-
gradio
|
| 14 |
-
tempfile
|
|
|
|
| 10 |
Unidecode
|
| 11 |
inflect
|
| 12 |
loguru
|
| 13 |
+
gradio
|
|
|