Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -91,6 +91,7 @@ import random
|
|
91 |
import base64
|
92 |
import os
|
93 |
import urllib.request
|
|
|
94 |
|
95 |
def function(Textbox, Textbox2, Textbox3, Dropdown):
|
96 |
target = os.environ.get("target")
|
@@ -216,10 +217,11 @@ def function(Textbox, Textbox2, Textbox3, Dropdown):
|
|
216 |
}
|
217 |
)
|
218 |
output = output["audio_out"]
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
|
|
223 |
except Exception as e:
|
224 |
print(traceback.format_exc())
|
225 |
return "Please Wait!"
|
@@ -234,8 +236,13 @@ inputs = [
|
|
234 |
|
235 |
]
|
236 |
|
|
|
|
|
|
|
|
|
237 |
# outputs = gr.outputs.Image(type="numpy")
|
238 |
-
outputs = gr.outputs.Audio(type="
|
|
|
239 |
|
240 |
iface = gr.Interface(fn=function, inputs=inputs, outputs=outputs)
|
241 |
|
|
|
91 |
import base64
|
92 |
import os
|
93 |
import urllib.request
|
94 |
+
from pydub import AudioSegment
|
95 |
|
96 |
def function(Textbox, Textbox2, Textbox3, Dropdown):
|
97 |
target = os.environ.get("target")
|
|
|
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!"
|
|
|
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 |
|