arif670 commited on
Commit
5a79a6d
·
verified ·
1 Parent(s): cde984a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -12
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("# English Language Learning App")
43
-
44
- with gr.Row():
45
- audio_input = gr.Audio(type="filepath", label="Speak into the microphone")
46
- text_output = gr.Textbox(label="Transcription")
47
- audio_output = gr.Audio(label="Feedback Audio")
48
-
49
- submit_button = gr.Button("Submit")
50
-
51
- submit_button.click(learn_english, inputs=audio_input, outputs=[text_output, audio_output])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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)