tommy24 commited on
Commit
ca945cc
·
1 Parent(s): 6720401

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -6
app.py CHANGED
@@ -217,15 +217,20 @@ def function(Textbox, Textbox2, Textbox3, Dropdown):
217
  }
218
  )
219
  output = output["audio_out"]
220
- audio_data = base64.b64decode(output)
 
 
 
 
 
221
  # return audio_data
222
 
223
- mp3_path = "output.mp3"
224
- with open(mp3_path, "wb") as f:
225
- f.write(audio_data)
226
 
227
  # Return the path to the MP3 file
228
- return mp3_path
229
  except Exception as e:
230
  print(traceback.format_exc())
231
  return "Please Wait!"
@@ -241,7 +246,7 @@ inputs = [
241
  ]
242
 
243
  # outputs = gr.outputs.Image(type="numpy")
244
- outputs = gr.outputs.Audio(type="numpy")
245
 
246
  iface = gr.Interface(fn=function, inputs=inputs, outputs=outputs)
247
 
 
217
  }
218
  )
219
  output = output["audio_out"]
220
+ def download_audio(url, output_file):
221
+ urllib.request.urlretrieve(url, output_file)
222
+
223
+ output_file = "audio.mp3"
224
+ download_audio(output, output_file)
225
+ # audio_data = base64.b64decode(output)
226
  # return audio_data
227
 
228
+ # mp3_path = "output.mp3"
229
+ # with open(mp3_path, "wb") as f:
230
+ # f.write(audio_data)
231
 
232
  # Return the path to the MP3 file
233
+ return output_file
234
  except Exception as e:
235
  print(traceback.format_exc())
236
  return "Please Wait!"
 
246
  ]
247
 
248
  # outputs = gr.outputs.Image(type="numpy")
249
+ outputs = gr.outputs.Audio(type="filepath")
250
 
251
  iface = gr.Interface(fn=function, inputs=inputs, outputs=outputs)
252