Spaces:
Runtime error
Runtime error
jinggujiwoo7
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -4,10 +4,6 @@ from Levenshtein import ratio
|
|
4 |
import tempfile
|
5 |
import numpy as np
|
6 |
import soundfile as sf
|
7 |
-
import language_tool_python
|
8 |
-
|
9 |
-
# Initialize LanguageTool for English grammar checking
|
10 |
-
tool = language_tool_python.LanguageTool('en-US')
|
11 |
|
12 |
def transcribe_audio(file_info):
|
13 |
r = sr.Recognizer()
|
@@ -40,33 +36,29 @@ def pronunciation_correction(expected_text, file_info):
|
|
40 |
|
41 |
return feedback, description
|
42 |
|
43 |
-
def
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
return corrected_text, feedback
|
48 |
|
49 |
with gr.Blocks() as app:
|
50 |
with gr.Row():
|
51 |
-
sentence_input = gr.Textbox(label="Enter
|
52 |
-
|
53 |
-
corrected_sentence_output = gr.Textbox(label="Corrected Sentence", interactive=False)
|
54 |
-
grammar_feedback = gr.Textbox(label="Grammar Feedback", interactive=False)
|
55 |
-
|
56 |
audio_input = gr.Audio(label="Upload Audio File", type="numpy")
|
57 |
check_pronunciation_button = gr.Button("Check Pronunciation")
|
58 |
pronunciation_feedback = gr.Textbox(label="Pronunciation Feedback")
|
59 |
pronunciation_score = gr.Number(label="Pronunciation Accuracy Score: 0 (No Match) ~ 1 (Perfect)")
|
60 |
|
61 |
-
|
62 |
-
|
63 |
inputs=sentence_input,
|
64 |
-
outputs=
|
65 |
)
|
66 |
-
|
67 |
check_pronunciation_button.click(
|
68 |
pronunciation_correction,
|
69 |
-
inputs=[
|
70 |
outputs=[pronunciation_feedback, pronunciation_score]
|
71 |
)
|
72 |
|
|
|
4 |
import tempfile
|
5 |
import numpy as np
|
6 |
import soundfile as sf
|
|
|
|
|
|
|
|
|
7 |
|
8 |
def transcribe_audio(file_info):
|
9 |
r = sr.Recognizer()
|
|
|
36 |
|
37 |
return feedback, description
|
38 |
|
39 |
+
def validate_sentence(sentence):
|
40 |
+
if not sentence.strip():
|
41 |
+
return "Please enter a sentence."
|
42 |
+
return sentence
|
|
|
43 |
|
44 |
with gr.Blocks() as app:
|
45 |
with gr.Row():
|
46 |
+
sentence_input = gr.Textbox(label="Enter Your Sentence Here")
|
47 |
+
validated_sentence = gr.Textbox(label="Valid Sentence", interactive=False)
|
|
|
|
|
|
|
48 |
audio_input = gr.Audio(label="Upload Audio File", type="numpy")
|
49 |
check_pronunciation_button = gr.Button("Check Pronunciation")
|
50 |
pronunciation_feedback = gr.Textbox(label="Pronunciation Feedback")
|
51 |
pronunciation_score = gr.Number(label="Pronunciation Accuracy Score: 0 (No Match) ~ 1 (Perfect)")
|
52 |
|
53 |
+
sentence_input.change(
|
54 |
+
validate_sentence,
|
55 |
inputs=sentence_input,
|
56 |
+
outputs=validated_sentence
|
57 |
)
|
58 |
+
|
59 |
check_pronunciation_button.click(
|
60 |
pronunciation_correction,
|
61 |
+
inputs=[validated_sentence, audio_input],
|
62 |
outputs=[pronunciation_feedback, pronunciation_score]
|
63 |
)
|
64 |
|