Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -103,6 +103,7 @@ try:
|
|
103 |
result += str_left_to_right + "\n"
|
104 |
st.write(str_left_to_right)
|
105 |
|
|
|
106 |
AUDIO_OUTPUT_FOLDER = "./output_audio"
|
107 |
os.makedirs(AUDIO_OUTPUT_FOLDER, exist_ok=True)
|
108 |
|
@@ -113,12 +114,9 @@ def text_to_speech_gtts(text, lang='en', filename="output.mp3"):
|
|
113 |
tts.save(audio_path)
|
114 |
return audio_path
|
115 |
|
116 |
-
# 示例检测结果文本
|
117 |
-
detected_text = "This is a sample Braille detection result."
|
118 |
-
|
119 |
try:
|
120 |
# 生成语音文件
|
121 |
-
audio_file_path = text_to_speech_gtts(
|
122 |
|
123 |
# 在 Streamlit 中播放音频
|
124 |
st.audio(audio_file_path, format="audio/mp3")
|
|
|
103 |
result += str_left_to_right + "\n"
|
104 |
st.write(str_left_to_right)
|
105 |
|
106 |
+
# 创建保存音频的文件夹
|
107 |
AUDIO_OUTPUT_FOLDER = "./output_audio"
|
108 |
os.makedirs(AUDIO_OUTPUT_FOLDER, exist_ok=True)
|
109 |
|
|
|
114 |
tts.save(audio_path)
|
115 |
return audio_path
|
116 |
|
|
|
|
|
|
|
117 |
try:
|
118 |
# 生成语音文件
|
119 |
+
audio_file_path = text_to_speech_gtts(result)
|
120 |
|
121 |
# 在 Streamlit 中播放音频
|
122 |
st.audio(audio_file_path, format="audio/mp3")
|