Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -51,7 +51,7 @@ def text2story(text):
|
|
51 |
generator = pipeline("text-generation", model="2173ars/llama-3-8b-Instruct-bnb-4bit-personal-shortstory")
|
52 |
|
53 |
# Create a prompt for the story
|
54 |
-
prompt = f"
|
55 |
|
56 |
# Generate the story - limit to a smaller max_length due to model size
|
57 |
story = generator(prompt,
|
@@ -137,6 +137,8 @@ async def text2audio_english(text):
|
|
137 |
# Apply custom CSS for modern, stylish kid-friendly UI
|
138 |
st.set_page_config(page_title="故事魔法", page_icon="✨", layout="wide")
|
139 |
|
|
|
|
|
140 |
st.markdown("""
|
141 |
<style>
|
142 |
/* Modern, stylish kid-friendly design */
|
@@ -341,10 +343,8 @@ st.markdown("""
|
|
341 |
""", unsafe_allow_html=True)
|
342 |
|
343 |
# App header with Cantonese
|
344 |
-
st.title("
|
345 |
-
st.markdown("<p class='
|
346 |
-
unsafe_allow_html=True)
|
347 |
-
|
348 |
# Add a progress indicator for model loading
|
349 |
progress_placeholder = st.empty()
|
350 |
|
@@ -448,9 +448,7 @@ if uploaded_file is not None:
|
|
448 |
if st.session_state.audio_path_en and os.path.exists(st.session_state.audio_path_en):
|
449 |
with open(st.session_state.audio_path_en, "rb") as audio_file:
|
450 |
audio_bytes = audio_file.read()
|
451 |
-
st.markdown("<div class='audio-container'>", unsafe_allow_html=True)
|
452 |
st.audio(audio_bytes, format="audio/mp3")
|
453 |
-
st.markdown("</div>", unsafe_allow_html=True)
|
454 |
else:
|
455 |
st.error("Sorry! Please try again.")
|
456 |
|
@@ -468,9 +466,7 @@ if uploaded_file is not None:
|
|
468 |
if st.session_state.audio_path_zh and os.path.exists(st.session_state.audio_path_zh):
|
469 |
with open(st.session_state.audio_path_zh, "rb") as audio_file:
|
470 |
audio_bytes = audio_file.read()
|
471 |
-
st.markdown("<div class='audio-container'>", unsafe_allow_html=True)
|
472 |
st.audio(audio_bytes, format="audio/mp3")
|
473 |
-
st.markdown("</div>", unsafe_allow_html=True)
|
474 |
else:
|
475 |
st.error("哎呀!再試多次啦!")
|
476 |
|
@@ -500,20 +496,4 @@ else:
|
|
500 |
st.session_state.audio_path_zh = None
|
501 |
st.session_state.audio_generated_en = False
|
502 |
st.session_state.audio_path_en = None
|
503 |
-
|
504 |
-
# Welcome message in Cantonese
|
505 |
-
st.markdown("""
|
506 |
-
<div class="welcome-message">
|
507 |
-
<div class="welcome-icon">✨</div>
|
508 |
-
<h2>歡迎嚟到故事魔法!</h2>
|
509 |
-
<p style="font-size: 1.2rem; color: #6B7897; max-width: 500px; margin: 0 auto 30px;">
|
510 |
-
上載一張你鍾意嘅相片,我哋嘅魔法師會幫你變出一個好好玩嘅故事!
|
511 |
-
</p>
|
512 |
-
<div>
|
513 |
-
<span class="emoji">🚀</span>
|
514 |
-
<span class="emoji">🦄</span>
|
515 |
-
<span class="emoji">🔮</span>
|
516 |
-
<span class="emoji">🌈</span>
|
517 |
-
</div>
|
518 |
-
</div>
|
519 |
-
""", unsafe_allow_html=True)
|
|
|
51 |
generator = pipeline("text-generation", model="2173ars/llama-3-8b-Instruct-bnb-4bit-personal-shortstory")
|
52 |
|
53 |
# Create a prompt for the story
|
54 |
+
prompt = f"{text}"
|
55 |
|
56 |
# Generate the story - limit to a smaller max_length due to model size
|
57 |
story = generator(prompt,
|
|
|
137 |
# Apply custom CSS for modern, stylish kid-friendly UI
|
138 |
st.set_page_config(page_title="故事魔法", page_icon="✨", layout="wide")
|
139 |
|
140 |
+
|
141 |
+
|
142 |
st.markdown("""
|
143 |
<style>
|
144 |
/* Modern, stylish kid-friendly design */
|
|
|
343 |
""", unsafe_allow_html=True)
|
344 |
|
345 |
# App header with Cantonese
|
346 |
+
st.title("")
|
347 |
+
st.markdown("<div class='welcome-message'><div class='welcome-icon'>✨</div><h2>歡迎嚟到故事魔法師!</h2> <p style='font-size: 1.2rem; color: #6B7897; max-width: 500px; margin: 0 auto 30px;'>上載一張你鍾意嘅相片,我哋嘅魔法師會幫你變出一個好好玩嘅故事!</p><div><span class='emoji'>🚀</span><span class='emoji'>🦄</span> <span class='emoji'>🔮</span><span class='emoji'>🌈</span></div></div>",unsafe_allow_html=True)
|
|
|
|
|
348 |
# Add a progress indicator for model loading
|
349 |
progress_placeholder = st.empty()
|
350 |
|
|
|
448 |
if st.session_state.audio_path_en and os.path.exists(st.session_state.audio_path_en):
|
449 |
with open(st.session_state.audio_path_en, "rb") as audio_file:
|
450 |
audio_bytes = audio_file.read()
|
|
|
451 |
st.audio(audio_bytes, format="audio/mp3")
|
|
|
452 |
else:
|
453 |
st.error("Sorry! Please try again.")
|
454 |
|
|
|
466 |
if st.session_state.audio_path_zh and os.path.exists(st.session_state.audio_path_zh):
|
467 |
with open(st.session_state.audio_path_zh, "rb") as audio_file:
|
468 |
audio_bytes = audio_file.read()
|
|
|
469 |
st.audio(audio_bytes, format="audio/mp3")
|
|
|
470 |
else:
|
471 |
st.error("哎呀!再試多次啦!")
|
472 |
|
|
|
496 |
st.session_state.audio_path_zh = None
|
497 |
st.session_state.audio_generated_en = False
|
498 |
st.session_state.audio_path_en = None
|
499 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|