lep1 commited on
Commit
583707e
1 Parent(s): 421058f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -102,15 +102,14 @@ try:
102
  str_left_to_right += convert_to_braille_unicode(model.names[int(each_class)])
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
 
110
  def text_to_speech_gtts(text, lang='en', filename="output.mp3"):
111
  """将文本转换为语音并保存音频文件"""
112
  tts = gTTS(text=text, lang=lang)
113
- audio_path = os.path.join(AUDIO_OUTPUT_FOLDER, filename)
114
  tts.save(audio_path)
115
  return audio_path
116
 
 
102
  str_left_to_right += convert_to_braille_unicode(model.names[int(each_class)])
103
  result += str_left_to_right + "\n"
104
  st.write(str_left_to_right)
105
+
106
+ except Exception as ex:
107
+ st.write("An error occurred while processing the audio.")
 
108
 
109
  def text_to_speech_gtts(text, lang='en', filename="output.mp3"):
110
  """将文本转换为语音并保存音频文件"""
111
  tts = gTTS(text=text, lang=lang)
112
+ audio_path = "./output_audio"
113
  tts.save(audio_path)
114
  return audio_path
115