Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -114,10 +114,11 @@ def compare_texts(reference_text, transcribed_text):
|
|
| 114 |
# Generate colored word score list
|
| 115 |
for i, word in enumerate(reference_words):
|
| 116 |
try:
|
| 117 |
-
|
|
|
|
| 118 |
word_score_list.append({"quality_score": 100, "word": word})
|
| 119 |
html_output += f'<span style="color: green;">{word}</span> ' # Correct words in green
|
| 120 |
-
elif difflib.get_close_matches(word, [transcribed_words[i]]):
|
| 121 |
word_score_list.append({"quality_score": 80, "word": word}) # Close matches
|
| 122 |
html_output += f'<span style="color: yellow;">{word}</span> ' # Close matches in yellow
|
| 123 |
else:
|
|
@@ -145,6 +146,7 @@ def compare_texts(reference_text, transcribed_text):
|
|
| 145 |
# Return structured data
|
| 146 |
return [html_output, word_score_list]
|
| 147 |
|
|
|
|
| 148 |
# Step 4: Text-to-Speech Function
|
| 149 |
def text_to_speech(paragraph):
|
| 150 |
if not paragraph:
|
|
|
|
| 114 |
# Generate colored word score list
|
| 115 |
for i, word in enumerate(reference_words):
|
| 116 |
try:
|
| 117 |
+
# Compare with transcribed words and assign quality scores
|
| 118 |
+
if i < len(transcribed_words) and word.lower() == transcribed_words[i].lower():
|
| 119 |
word_score_list.append({"quality_score": 100, "word": word})
|
| 120 |
html_output += f'<span style="color: green;">{word}</span> ' # Correct words in green
|
| 121 |
+
elif i < len(transcribed_words) and difflib.get_close_matches(word, [transcribed_words[i]]):
|
| 122 |
word_score_list.append({"quality_score": 80, "word": word}) # Close matches
|
| 123 |
html_output += f'<span style="color: yellow;">{word}</span> ' # Close matches in yellow
|
| 124 |
else:
|
|
|
|
| 146 |
# Return structured data
|
| 147 |
return [html_output, word_score_list]
|
| 148 |
|
| 149 |
+
|
| 150 |
# Step 4: Text-to-Speech Function
|
| 151 |
def text_to_speech(paragraph):
|
| 152 |
if not paragraph:
|