Upload 2 files
Browse files- app.py +23 -0
- requirements.txt +4 -0
app.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
import torch
|
| 4 |
+
|
| 5 |
+
# モデルのロード (例: Tacotron2 + WaveGlow)
|
| 6 |
+
synthesizer = pipeline("text-to-speech", "tts_model_name", device=0) # モデル名を指定, GPUを使う場合は device=0
|
| 7 |
+
|
| 8 |
+
# 推論関数の定義
|
| 9 |
+
def synthesize_speech(text):
|
| 10 |
+
with torch.no_grad():
|
| 11 |
+
audio = synthesizer(text)
|
| 12 |
+
return (synthesizer.sampling_rate, audio["audio"].numpy())
|
| 13 |
+
|
| 14 |
+
# Gradioインターフェースの作成
|
| 15 |
+
iface = gr.Interface(
|
| 16 |
+
fn=synthesize_speech,
|
| 17 |
+
inputs=gr.Textbox(lines=5, label="Input Text"),
|
| 18 |
+
outputs=gr.Audio(label="Output Audio"),
|
| 19 |
+
title="TTS Demo",
|
| 20 |
+
description="Enter text to synthesize speech."
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
iface.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
transformers
|
| 3 |
+
torch
|
| 4 |
+
espnet
|