Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -871,10 +871,12 @@ def listen_in_hindi(response_text):
|
|
871 |
output_format="mp3_44100_128",
|
872 |
)
|
873 |
|
874 |
-
#
|
875 |
-
|
|
|
|
|
876 |
|
877 |
-
return "Audio
|
878 |
|
879 |
except Exception as e:
|
880 |
logging.error(f"Error in 'listen_in_hindi': {e}")
|
@@ -946,6 +948,8 @@ with gr.Blocks(css=custom_css, theme="soft") as demo:
|
|
946 |
|
947 |
# "Listen this in Hindi" button
|
948 |
listen_button = gr.Button("Listen to this in Hindi", interactive=False)
|
|
|
|
|
949 |
|
950 |
# Define the interaction logic
|
951 |
submit_button.click(
|
@@ -962,7 +966,7 @@ with gr.Blocks(css=custom_css, theme="soft") as demo:
|
|
962 |
listen_button.click(
|
963 |
fn=lambda chat_history: listen_in_hindi(get_last_bot_response(chat_history)),
|
964 |
inputs=chatbot,
|
965 |
-
outputs=
|
966 |
)
|
967 |
|
968 |
question_textbox.change(
|
|
|
871 |
output_format="mp3_44100_128",
|
872 |
)
|
873 |
|
874 |
+
# Save to file
|
875 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as f:
|
876 |
+
f.write(audio_bytes)
|
877 |
+
audio_path = f.name
|
878 |
|
879 |
+
return audio_path, "Audio in Hindi generated successfully!"
|
880 |
|
881 |
except Exception as e:
|
882 |
logging.error(f"Error in 'listen_in_hindi': {e}")
|
|
|
948 |
|
949 |
# "Listen this in Hindi" button
|
950 |
listen_button = gr.Button("Listen to this in Hindi", interactive=False)
|
951 |
+
audio_output = gr.Audio(label="Hindi Audio", type="filepath")
|
952 |
+
status_output = gr.Textbox(label="Status")
|
953 |
|
954 |
# Define the interaction logic
|
955 |
submit_button.click(
|
|
|
966 |
listen_button.click(
|
967 |
fn=lambda chat_history: listen_in_hindi(get_last_bot_response(chat_history)),
|
968 |
inputs=chatbot,
|
969 |
+
outputs=[audio_output, status_output]
|
970 |
)
|
971 |
|
972 |
question_textbox.change(
|