Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
import openai
|
3 |
import speech_recognition as sr
|
@@ -45,9 +46,6 @@ def get_pronunciation_feedback(original_text, transcription):
|
|
45 |
return "Error generating feedback. Please try again."
|
46 |
|
47 |
def transcribe_audio_realtime(audio):
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
try:
|
52 |
logger.debug(f"Received audio file: {audio}")
|
53 |
recognizer = sr.Recognizer()
|
@@ -85,3 +83,27 @@ def practice_pronunciation(audio, text_to_read):
|
|
85 |
logger.info(f"Feedback generated: {feedback}")
|
86 |
|
87 |
return text_to_read, transcription, feedback
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
import gradio as gr
|
3 |
import openai
|
4 |
import speech_recognition as sr
|
|
|
46 |
return "Error generating feedback. Please try again."
|
47 |
|
48 |
def transcribe_audio_realtime(audio):
|
|
|
|
|
|
|
49 |
try:
|
50 |
logger.debug(f"Received audio file: {audio}")
|
51 |
recognizer = sr.Recognizer()
|
|
|
83 |
logger.info(f"Feedback generated: {feedback}")
|
84 |
|
85 |
return text_to_read, transcription, feedback
|
86 |
+
|
87 |
+
# Gradio interface
|
88 |
+
with gr.Blocks() as demo:
|
89 |
+
gr.Markdown("# Pronunciation Practice Tool")
|
90 |
+
gr.Markdown("Generate a text to read, then record yourself reading it. The system will provide pronunciation feedback.")
|
91 |
+
|
92 |
+
with gr.Row():
|
93 |
+
text_to_read = gr.Textbox(label="Text to Read")
|
94 |
+
generate_button = gr.Button("Generate New Text")
|
95 |
+
|
96 |
+
audio_input = gr.Audio(type="filepath", label="Record your voice")
|
97 |
+
|
98 |
+
with gr.Row():
|
99 |
+
transcription_output = gr.Textbox(label="Your Transcription")
|
100 |
+
feedback_output = gr.Textbox(label="Pronunciation Feedback")
|
101 |
+
|
102 |
+
submit_button = gr.Button("Submit")
|
103 |
+
|
104 |
+
generate_button.click(generate_text, outputs=text_to_read)
|
105 |
+
submit_button.click(practice_pronunciation, inputs=[audio_input, text_to_read], outputs=[text_to_read, transcription_output, feedback_output])
|
106 |
+
|
107 |
+
# Launch the app
|
108 |
+
if __name__ == "__main__":
|
109 |
+
demo.launch()
|