Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,10 +1,7 @@
|
|
1 |
-
import
|
2 |
-
import asyncio
|
3 |
-
import edge_tts
|
4 |
import gradio as gr
|
5 |
|
6 |
-
|
7 |
-
VOICE = "en-US-RyanNeural"
|
8 |
|
9 |
# μ€ν 리 λ°μ΄ν° (ν
μ€νΈ + μ΄λ―Έμ§ URL ν¬ν¨)
|
10 |
image_base_url = "https://huggingface.co/spaces/englissi/englishstories/resolve/main/image/"
|
@@ -21,22 +18,26 @@ stories = [
|
|
21 |
{"text": "Fun in the sun is the best!", "image": f"{image_base_url}10.webp"}
|
22 |
]
|
23 |
|
24 |
-
|
25 |
-
async def generate_audio_async(text, filename="story.mp3"):
|
26 |
try:
|
27 |
-
|
28 |
-
|
|
|
29 |
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
32 |
print(f"β
μμ± νμΌ μμ± μλ£: {filename}")
|
33 |
return filename
|
34 |
else:
|
35 |
-
print("β οΈ μμ±
|
36 |
return None
|
37 |
-
|
38 |
except Exception as e:
|
39 |
-
print(f"β οΈ
|
40 |
return None
|
41 |
|
42 |
|
|
|
1 |
+
import requests
|
|
|
|
|
2 |
import gradio as gr
|
3 |
|
4 |
+
|
|
|
5 |
|
6 |
# μ€ν 리 λ°μ΄ν° (ν
μ€νΈ + μ΄λ―Έμ§ URL ν¬ν¨)
|
7 |
image_base_url = "https://huggingface.co/spaces/englissi/englishstories/resolve/main/image/"
|
|
|
18 |
{"text": "Fun in the sun is the best!", "image": f"{image_base_url}10.webp"}
|
19 |
]
|
20 |
|
21 |
+
def generate_audio(text, filename="story.mp3"):
|
|
|
22 |
try:
|
23 |
+
# λ‘컬 Fish Speech μλ² μ£Όμ
|
24 |
+
api_url = "http://localhost:8080/tts"
|
25 |
+
data = {"text": text, "speaker": "en_us_male"} # νμ μ€μ (νμμ λ°λΌ λ³κ²½)
|
26 |
|
27 |
+
# Fish Speech μλ²μ μμ² λ³΄λ΄κΈ°
|
28 |
+
response = requests.post(api_url, json=data)
|
29 |
+
|
30 |
+
# μλ΅ νμΈ λ° μμ± μ μ₯
|
31 |
+
if response.status_code == 200:
|
32 |
+
with open(filename, "wb") as f:
|
33 |
+
f.write(response.content)
|
34 |
print(f"β
μμ± νμΌ μμ± μλ£: {filename}")
|
35 |
return filename
|
36 |
else:
|
37 |
+
print(f"β οΈ μμ± μμ± μ€ν¨: {response.status_code}")
|
38 |
return None
|
|
|
39 |
except Exception as e:
|
40 |
+
print(f"β οΈ μ€λ₯ λ°μ: {e}")
|
41 |
return None
|
42 |
|
43 |
|