Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -226,31 +226,25 @@ def predict_category(que, input_image):
|
|
226 |
return preds[0]
|
227 |
|
228 |
|
229 |
-
def combine(
|
230 |
-
|
231 |
-
|
232 |
-
else:
|
233 |
-
que = transcribe_audio(audio)
|
234 |
|
235 |
image = Image.fromarray(input_image).convert('RGB')
|
236 |
category = predict_category(que, image)
|
237 |
|
238 |
answer = predict_answer(0, que, image)
|
239 |
|
|
|
|
|
240 |
tts = gTTS(answer)
|
241 |
tts.save('answer.mp3')
|
242 |
return que, answer, 'answer.mp3'
|
243 |
|
244 |
|
245 |
-
model_interface = gr.Interface(fn=combine,
|
246 |
-
inputs=[gr.inputs.Textbox(label="Text Question"),
|
247 |
-
gr.inputs.Microphone(label="Audio Question", type="audio", source="microphone"),
|
248 |
-
gr.inputs.Image(label="Upload the image")],
|
249 |
-
outputs=[gr.outputs.Text(label="Transcribed Question"),
|
250 |
-
gr.outputs.Text(label="Answer"),
|
251 |
-
gr.outputs.Audio(label="Audio Answer")])
|
252 |
-
|
253 |
|
|
|
|
|
254 |
# image_upload_interface = gr.Interface(fn=upload_image, inputs=gr.Image(label="Upload the image"), outputs="text")
|
255 |
|
256 |
# Launch the Gradio interface
|
|
|
226 |
return preds[0]
|
227 |
|
228 |
|
229 |
+
def combine(audio, input_image):
|
230 |
+
que = transcribe_audio(audio)
|
231 |
+
# que = "What is the animal here?"
|
|
|
|
|
232 |
|
233 |
image = Image.fromarray(input_image).convert('RGB')
|
234 |
category = predict_category(que, image)
|
235 |
|
236 |
answer = predict_answer(0, que, image)
|
237 |
|
238 |
+
# print(category)
|
239 |
+
|
240 |
tts = gTTS(answer)
|
241 |
tts.save('answer.mp3')
|
242 |
return que, answer, 'answer.mp3'
|
243 |
|
244 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
245 |
|
246 |
+
# Define the Gradio interface for recording audio and displaying the transcription
|
247 |
+
model_interface = gr.Interface(fn=combine, inputs=[gr.Microphone(label="Ask your question"),gr.Image(label="Upload the image")], outputs=[gr.Text(label="Transcribed Question"), gr.Text(label="Answer"), gr.Audio(label="Audio Answer")])
|
248 |
# image_upload_interface = gr.Interface(fn=upload_image, inputs=gr.Image(label="Upload the image"), outputs="text")
|
249 |
|
250 |
# Launch the Gradio interface
|