HusseinBashir commited on
Commit
353cc34
·
verified ·
1 Parent(s): c021cc9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -9
app.py CHANGED
@@ -75,19 +75,16 @@ def normalize_text(text):
75
  return text
76
 
77
  def tts(text):
78
- text = normalize_text(text)
79
- inputs = tokenizer(text, return_tensors="pt").to(device)
80
- with torch.no_grad():
81
- waveform = model(**inputs).waveform.squeeze().cpu().numpy()
82
  filename = "output.wav"
83
  scipy.io.wavfile.write(filename, rate=model.config.sampling_rate, data=(waveform * 32767).astype(np.int16))
84
- return filename # let Gradio handle file URL
85
 
86
- # ✅ This enables API access!
87
  gr.Interface(
88
  fn=tts,
89
  inputs=gr.Textbox(label="Geli qoraal Soomaali ah"),
90
- outputs=gr.Audio(type="filepath", label="Codka TTS"),
91
  title="Somali TTS",
92
- description="Ku qor qoraal Soomaali ah si aad u maqasho codka.",
93
- ).queue().launch()
 
 
75
  return text
76
 
77
  def tts(text):
78
+ ...
 
 
 
79
  filename = "output.wav"
80
  scipy.io.wavfile.write(filename, rate=model.config.sampling_rate, data=(waveform * 32767).astype(np.int16))
81
+ return filename # This returns "output.wav"
82
 
 
83
  gr.Interface(
84
  fn=tts,
85
  inputs=gr.Textbox(label="Geli qoraal Soomaali ah"),
86
+ outputs=gr.Audio(type="filepath", label="Codka TTS"), # ✅ filepath is required
87
  title="Somali TTS",
88
+ description="Ku qor qoraal Soomaali ah si aad u maqasho codka."
89
+ ).queue().launch() # ✅ Enables API endpoint /run/predict
90
+