Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -59,7 +59,9 @@ def compare_texts(reference_text, transcribed_text):
|
|
59 |
html_output += f'<span style="color: red;">{word}</span> '
|
60 |
# Create pronunciation audio for the incorrect word
|
61 |
audio_buffer = create_pronunciation_audio(word)
|
62 |
-
|
|
|
|
|
63 |
except IndexError:
|
64 |
html_output += f'<span style="color: red;">{word}</span> ' # Words in reference that were not transcribed
|
65 |
|
@@ -69,7 +71,7 @@ def compare_texts(reference_text, transcribed_text):
|
|
69 |
for word, audio in incorrect_words_audios:
|
70 |
html_output += f'{word}: '
|
71 |
# Return the audio buffer as part of the HTML output
|
72 |
-
html_output += f'<audio controls><source src="data:audio/mp3;base64,{audio
|
73 |
|
74 |
return html_output
|
75 |
|
|
|
59 |
html_output += f'<span style="color: red;">{word}</span> '
|
60 |
# Create pronunciation audio for the incorrect word
|
61 |
audio_buffer = create_pronunciation_audio(word)
|
62 |
+
# Encode the audio as base64 for playback
|
63 |
+
audio_base64 = audio_buffer.getvalue().hex()
|
64 |
+
incorrect_words_audios.append((word, audio_base64))
|
65 |
except IndexError:
|
66 |
html_output += f'<span style="color: red;">{word}</span> ' # Words in reference that were not transcribed
|
67 |
|
|
|
71 |
for word, audio in incorrect_words_audios:
|
72 |
html_output += f'{word}: '
|
73 |
# Return the audio buffer as part of the HTML output
|
74 |
+
html_output += f'<audio controls><source src="data:audio/mp3;base64,{audio}" type="audio/mpeg">Your browser does not support the audio tag.</audio><br>'
|
75 |
|
76 |
return html_output
|
77 |
|