File size: 1,660 Bytes
21ae21d 043b257 21ae21d 7438e97 1fa7b92 21ae21d 590ca89 21ae21d 575cef2 21ae21d 575cef2 21ae21d a58b40e 575cef2 a58b40e 575cef2 21ae21d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
import gradio as gr
from huggingface_hub import hf_hub_download
from sbv2_bindings import TTSModel
bert = hf_hub_download("googlefan/sbv2_onnx_models", "deberta.onnx")
tokenizer = hf_hub_download("googlefan/sbv2_onnx_models", "tokenizer.json")
def load_and_synthesize(text: str, path: str, sdp: float = 0.0, speed: float = 1.0):
model = TTSModel.from_path(bert, tokenizer)
uid = "default"
path = path.split("/")
filename = "/".join(path[2:])
repo_id = "/".join(path[:2])
model.load_sbv2file_from_path(uid, hf_hub_download(repo_id, filename))
print("All setup is done!")
return model.synthesize(text, uid, 0, sdp, 1.0 / speed)
iface = gr.Interface(
fn=load_and_synthesize,
concurrency_limit=1,
inputs=[
gr.Textbox(lines=2, placeholder="テキスト"),
gr.Textbox(lines=1, max_lines=1, placeholder="パス"),
gr.Slider(minimum=0.0, maximum=1.0, step=0.01, value=0.0, label="SDP"),
gr.Slider(minimum=0.5, maximum=2.0, step=0.1, value=1.0, label="Speed"),
],
outputs="audio",
title="SBV2音声合成",
description="テキストとモデルのパスを入力して音声を生成します。SDPと速度を調整して音声の質を変更できます。",
examples=[
[
"おはようございます。",
"googlefan/sbv2_personal_models/tsukuyomi.sbv2",
0.0,
1.0,
],
[
"今日の天気は晴れです。場所によっては雨が降るでしょう。",
"googlefan/sbv2_personal_models/iroha.sbv2",
0.0,
1.1,
],
],
)
iface.launch()
|