Spaces:
Runtime error
Runtime error
Upload 2 files
Browse files- app.py +4 -1
- 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
|