tommy24 commited on
Commit
3b3f91f
·
1 Parent(s): 958b1cc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -24
app.py CHANGED
@@ -217,36 +217,30 @@ def function(Textbox, Textbox2, Textbox3, Dropdown):
217
  }
218
  )
219
  output = output["audio_out"]
220
- return output
221
- # mp3_data = BytesIO()
222
- # output.export(mp3_data, format="mp3")
223
- # mp3_data.seek(0)
224
- # return mp3_data.read()
225
  except Exception as e:
226
  print(traceback.format_exc())
227
  return "Please Wait!"
228
  else:
229
  return "Failed"
230
 
231
- inputs = [
232
- gr.inputs.Textbox(label="Textbox", type="text"),
233
- gr.inputs.Textbox(label="Textbox2", type="text"),
234
- gr.inputs.Textbox(label="Textbox3", type="password"),
235
- gr.inputs.Dropdown(["Option1", "Option2"], label="Dropdown")
236
-
237
- ]
238
-
239
- def audio_format(data):
240
- audio = AudioSegment.from_file(BytesIO(data), format="mp3")
241
- return audio
242
-
243
- # outputs = gr.outputs.Image(type="numpy")
244
- outputs = gr.outputs.Textbox() if Dropdown == "Option1" else gr.outputs.Audio(type="bytes", label="Audio Output", format="mp3")
245
-
246
-
247
- iface = gr.Interface(fn=function, inputs=inputs, outputs=outputs)
248
-
249
- iface.launch()
250
 
251
 
252
 
 
217
  }
218
  )
219
  output = output["audio_out"]
220
+ mp3_data = BytesIO()
221
+ output.export(mp3_data, format="mp3")
222
+ mp3_data.seek(0)
223
+ return mp3_data.read()
 
224
  except Exception as e:
225
  print(traceback.format_exc())
226
  return "Please Wait!"
227
  else:
228
  return "Failed"
229
 
230
+ inputs = [
231
+ gr.inputs.Textbox(label="Textbox", type="text"),
232
+ gr.inputs.Textbox(label="Textbox2", type="text"),
233
+ gr.inputs.Textbox(label="Textbox3", type="password"),
234
+ gr.inputs.Dropdown(["Option1", "Option2"], label="Dropdown")
235
+
236
+ ]
237
+
238
+ # outputs = gr.outputs.Image(type="numpy")
239
+ outputs = gr.outputs.Audio(type="filepath")
240
+
241
+ iface = gr.Interface(fn=function, inputs=inputs, outputs=outputs)
242
+
243
+ iface.launch()
 
 
 
 
 
244
 
245
 
246