ninumm commited on
Commit
ee9e018
·
1 Parent(s): 66b9e70
Files changed (1) hide show
  1. ttsFB.py +5 -6
ttsFB.py CHANGED
@@ -18,11 +18,9 @@ def tts(lang, text):
18
  with torch.no_grad():
19
  output = model(**inputs).waveform
20
 
21
- audio = gr.Audio(type="numpy", label="語音輸出") # 使用 numpy 格式
22
-
23
- # output_np = output.squeeze().cpu().numpy() # 去除多餘維度並轉為 NumPy
24
- # scipy.io.wavfile.write(f"{fileName}.wav", rate=model.config.sampling_rate, data=output_np)
25
- return audio
26
 
27
  iface = gr.Interface(
28
  fn=tts,
@@ -31,7 +29,8 @@ iface = gr.Interface(
31
  gr.Textbox(label="輸入文字 (Text)"), # 輸入的文字
32
  # gr.Textbox(label="檔案名稱 (File Name)"), # 輸入檔案名稱
33
  ],
34
- outputs=gr.Audio(type="file", label="語音輸出") # 輸出語音
 
35
  )
36
 
37
  iface.launch()
 
18
  with torch.no_grad():
19
  output = model(**inputs).waveform
20
 
21
+ output_np = output.squeeze().cpu().numpy() # 去除多餘維度並轉為 NumPy
22
+ # file = scipy.io.wavfile.write(f"{fileName}.wav", rate=model.config.sampling_rate, data=output_np)
23
+ return (model.config.sampling_rate, output_np) # 返回取樣率和 NumPy 音訊數據
 
 
24
 
25
  iface = gr.Interface(
26
  fn=tts,
 
29
  gr.Textbox(label="輸入文字 (Text)"), # 輸入的文字
30
  # gr.Textbox(label="檔案名稱 (File Name)"), # 輸入檔案名稱
31
  ],
32
+ outputs=gr.Audio(type="numpy", label="語音輸出"), # 輸出語音
33
+ allow_flagging="never" # 移除 Flag 按鈕
34
  )
35
 
36
  iface.launch()