Upload 2 files
Browse files- app.py +6 -4
- requirements.txt +1 -1
app.py
CHANGED
@@ -1,15 +1,17 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
|
|
3 |
import torch
|
4 |
|
5 |
-
# モデルのロード (例:
|
6 |
-
synthesizer = pipeline("text-to-speech", "
|
7 |
|
8 |
# 推論関数の定義
|
9 |
def synthesize_speech(text):
|
10 |
with torch.no_grad():
|
11 |
-
|
12 |
-
|
|
|
13 |
|
14 |
# Gradioインターフェースの作成
|
15 |
iface = gr.Interface(
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
+
import soundfile as sf
|
4 |
import torch
|
5 |
|
6 |
+
# モデルのロード (例: speechbrain/tts-hifigan-ljspeech)
|
7 |
+
synthesizer = pipeline("text-to-speech", "speechbrain/tts-hifigan-ljspeech")
|
8 |
|
9 |
# 推論関数の定義
|
10 |
def synthesize_speech(text):
|
11 |
with torch.no_grad():
|
12 |
+
output = synthesizer(text)
|
13 |
+
sf.write("speech.wav", output["audio"], output["sampling_rate"]) #numpy arrayからwavファイルに変換
|
14 |
+
return "speech.wav"
|
15 |
|
16 |
# Gradioインターフェースの作成
|
17 |
iface = gr.Interface(
|
requirements.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
gradio
|
2 |
transformers
|
3 |
torch
|
4 |
-
|
|
|
1 |
gradio
|
2 |
transformers
|
3 |
torch
|
4 |
+
soundfile
|