Jiangxz commited on
Commit
130be7c
ยท
verified ยท
1 Parent(s): 7eb1482

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +4 -1
  2. requirements.txt +1 -0
app.py CHANGED
@@ -4,6 +4,7 @@
4
  import gradio as gr
5
  import openai
6
  from pydub import AudioSegment
 
7
  import uuid
8
  import edge_tts
9
  import json
@@ -122,6 +123,8 @@ Follow this JSON example structure, MUST be in {language} language:
122
  podcast_match = re.search(r'{.*}', response.choices[0].message.content, re.DOTALL)
123
  if podcast_match:
124
  podcast_json = podcast_match.group(0)
 
 
125
  try:
126
  json.loads(podcast_json)
127
  except json.JSONDecodeError:
@@ -131,7 +134,7 @@ Follow this JSON example structure, MUST be in {language} language:
131
  gr.Info(f"ๅทฒๆˆๅŠŸ็”Ÿๆˆ Podcast ๅЇๆœฌ๏ผŒๅŸท่กŒๆ™‚้–“๏ผš {(end_time - start_time):.2f} ็ง’ใ€‚")
132
  return podcast_json
133
  else:
134
- raise gr.Error("็”Ÿๆˆ Podcast ๅЇๆœฌๅคฑๆ•—๏ผ๏ผ่ซ‹็จๅพŒๅ†่ฉฆใ€‚")
135
  except Exception as e:
136
  if "API key not valid" in str(e):
137
  raise gr.Error("็„กๆ•ˆ็š„ API ้‡‘้‘ฐ๏ผ๏ผ่ซ‹ๆไพ›ๆœ‰ๆ•ˆ็š„ API ้‡‘้‘ฐใ€‚")
 
4
  import gradio as gr
5
  import openai
6
  from pydub import AudioSegment
7
+ from zhconv_rs import zhconv
8
  import uuid
9
  import edge_tts
10
  import json
 
123
  podcast_match = re.search(r'{.*}', response.choices[0].message.content, re.DOTALL)
124
  if podcast_match:
125
  podcast_json = podcast_match.group(0)
126
+ if language == "็น้ซ”ไธญๆ–‡":
127
+ podcast_json = zhconv(podcast_json, "zh-tw")
128
  try:
129
  json.loads(podcast_json)
130
  except json.JSONDecodeError:
 
134
  gr.Info(f"ๅทฒๆˆๅŠŸ็”Ÿๆˆ Podcast ๅЇๆœฌ๏ผŒๅŸท่กŒๆ™‚้–“๏ผš {(end_time - start_time):.2f} ็ง’ใ€‚")
135
  return podcast_json
136
  else:
137
+ raise gr.Error("็”Ÿๆˆ Podcast ๅЇๆœฌๅคฑๆ•—๏ผ่ซ‹็จๅพŒ้‡่ฉฆๆˆ–ๆธ›ๅฐ‘่ฉฑ้กŒๅ…งๅฎน๏ผ")
138
  except Exception as e:
139
  if "API key not valid" in str(e):
140
  raise gr.Error("็„กๆ•ˆ็š„ API ้‡‘้‘ฐ๏ผ๏ผ่ซ‹ๆไพ›ๆœ‰ๆ•ˆ็š„ API ้‡‘้‘ฐใ€‚")
requirements.txt CHANGED
@@ -3,4 +3,5 @@ openai
3
  pydub
4
  edge-tts
5
  aiofiles
 
6
  pypdf
 
3
  pydub
4
  edge-tts
5
  aiofiles
6
+ zhconv-rs
7
  pypdf