Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -33,22 +33,47 @@ def text_to_speech(text):
|
|
| 33 |
# Function to handle the entire flow
|
| 34 |
def learn_english(audio):
|
| 35 |
user_input = speech_to_text(audio)
|
| 36 |
-
feedback = f"You said: {user_input}. Great job! Let's practice more."
|
| 37 |
audio_feedback = text_to_speech(feedback)
|
| 38 |
return feedback, audio_feedback
|
| 39 |
|
| 40 |
# Create Gradio Interface
|
| 41 |
-
with gr.Blocks() as demo:
|
| 42 |
-
gr.Markdown("
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
# Launch the app
|
| 54 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
| 33 |
# Function to handle the entire flow
|
| 34 |
def learn_english(audio):
|
| 35 |
user_input = speech_to_text(audio)
|
| 36 |
+
feedback = f"You said: '{user_input}'. Great job! Let's practice more."
|
| 37 |
audio_feedback = text_to_speech(feedback)
|
| 38 |
return feedback, audio_feedback
|
| 39 |
|
| 40 |
# Create Gradio Interface
|
| 41 |
+
with gr.Blocks(theme=gr.themes.Soft()) as demo: # Use a modern theme
|
| 42 |
+
gr.Markdown("""
|
| 43 |
+
# 🌟 English Language Learning App 🌟
|
| 44 |
+
Welcome to the English Language Learning App!
|
| 45 |
+
- Speak into the microphone, and the app will transcribe your speech.
|
| 46 |
+
- It will then provide feedback in both text and audio formats.
|
| 47 |
+
""")
|
| 48 |
+
|
| 49 |
+
with gr.Row(): # Organize components in rows
|
| 50 |
+
with gr.Column(scale=1): # Left column for input
|
| 51 |
+
gr.Markdown("### Step 1: Record Your Voice")
|
| 52 |
+
audio_input = gr.Audio(
|
| 53 |
+
type="filepath",
|
| 54 |
+
label="🎤 Speak into the Microphone",
|
| 55 |
+
interactive=True
|
| 56 |
+
)
|
| 57 |
+
submit_button = gr.Button("Submit", variant="primary")
|
| 58 |
+
|
| 59 |
+
with gr.Column(scale=2): # Right column for output
|
| 60 |
+
gr.Markdown("### Step 2: View Feedback")
|
| 61 |
+
text_output = gr.Textbox(
|
| 62 |
+
label="📝 Transcription",
|
| 63 |
+
placeholder="Your transcription will appear here...",
|
| 64 |
+
lines=3
|
| 65 |
+
)
|
| 66 |
+
audio_output = gr.Audio(
|
| 67 |
+
label="🎧 Audio Feedback",
|
| 68 |
+
autoplay=True
|
| 69 |
+
)
|
| 70 |
+
|
| 71 |
+
# Bind the button to the function
|
| 72 |
+
submit_button.click(
|
| 73 |
+
learn_english,
|
| 74 |
+
inputs=audio_input,
|
| 75 |
+
outputs=[text_output, audio_output]
|
| 76 |
+
)
|
| 77 |
|
| 78 |
# Launch the app
|
| 79 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|