miya3333 commited on
Commit
881ca56
·
verified ·
1 Parent(s): a152706

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +6 -4
  2. 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
- # モデルのロード (例: 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(
 
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
- espnet
 
1
  gradio
2
  transformers
3
  torch
4
+ soundfile