Spaces:
Sleeping
Sleeping
seawolf2357
commited on
Commit
β’
4862dc2
1
Parent(s):
2f686d1
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,9 @@
|
|
1 |
import streamlit as st
|
2 |
import requests
|
3 |
-
|
|
|
|
|
|
|
4 |
|
5 |
# νμ΄μ§ μ€μ
|
6 |
st.set_page_config(page_title="ViDraft", layout="wide")
|
@@ -24,19 +27,20 @@ if 'current_menu' not in st.session_state:
|
|
24 |
if 'current_sub_menu' not in st.session_state:
|
25 |
st.session_state['current_sub_menu'] = ''
|
26 |
|
27 |
-
# λ©μΈ λ©λ΄ μ ν
|
28 |
-
selected_menu = st.sidebar.selectbox("Menu", list(menus.keys()))
|
29 |
st.session_state['current_menu'] = selected_menu
|
30 |
|
31 |
-
# μ¬κΈ°μμ `selected_menu` λ³μκ° μ΄λ―Έ μ μλμμ΅λλ€. μ΄μ νμ λ©λ΄ μ ν μ΄ν μ¬μ©μ΄ μμλ©λλ€.
|
32 |
-
|
33 |
# νμ λ©λ΄ μ ν (ν΄λΉλλ κ²½μ°)
|
34 |
if selected_menu in menus:
|
35 |
-
|
|
|
36 |
st.session_state['current_sub_menu'] = selected_sub_menu
|
37 |
else:
|
38 |
st.session_state['current_sub_menu'] = ''
|
39 |
|
|
|
|
|
40 |
# μ¬κΈ°μλΆν° `selected_menu` λ³μλ₯Ό κΈ°λ°μΌλ‘ 쑰건문μ μ¬μ©νλ λλ¨Έμ§ μ½λκ° μ¬λ°λ₯΄κ² μλν κ²μ
λλ€.
|
41 |
|
42 |
# Pexels API ν€ μ€μ
|
@@ -84,7 +88,37 @@ if selected_menu == "Free Stock" and st.session_state['current_sub_menu'] == "Se
|
|
84 |
with cols[idx % 3]:
|
85 |
st.video(video)
|
86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
# 'Home' νμ΄μ§ νμ
|
89 |
if selected_menu == "Home":
|
90 |
st.header("Welcome to ViDraft")
|
@@ -114,9 +148,7 @@ elif selected_menu == "Image":
|
|
114 |
elif st.session_state['current_sub_menu'] == "Inpainting":
|
115 |
st.header("Inpainting")
|
116 |
st.write("Fill in missing parts of images.")
|
117 |
-
|
118 |
-
st.header("Remove Background")
|
119 |
-
st.write("Easily remove backgrounds from images.")
|
120 |
elif st.session_state['current_sub_menu'] == "Studio":
|
121 |
st.header("Image Studio")
|
122 |
st.write("Access a suite of image editing tools.")
|
@@ -144,9 +176,6 @@ elif selected_menu == "Sound":
|
|
144 |
elif st.session_state['current_sub_menu'] == "Video Music":
|
145 |
st.header("Video Music")
|
146 |
st.write("Find the perfect music for your video content.")
|
147 |
-
elif st.session_state['current_sub_menu'] == "TTS(Voice)":
|
148 |
-
st.header("Text-to-Speech")
|
149 |
-
st.write("Convert your text into natural-sounding voice.")
|
150 |
elif st.session_state['current_sub_menu'] == "Image SFX":
|
151 |
st.header("Image Sound Effects")
|
152 |
st.write("Add sound effects to your images.")
|
|
|
1 |
import streamlit as st
|
2 |
import requests
|
3 |
+
import streamlit.components.v1 as components
|
4 |
+
from gtts import gTTS
|
5 |
+
import os
|
6 |
+
from io import BytesIO
|
7 |
|
8 |
# νμ΄μ§ μ€μ
|
9 |
st.set_page_config(page_title="ViDraft", layout="wide")
|
|
|
27 |
if 'current_sub_menu' not in st.session_state:
|
28 |
st.session_state['current_sub_menu'] = ''
|
29 |
|
30 |
+
# λ©μΈ λ©λ΄ μ ν - μ€λ³΅ μ κ±° ν νλλ§ λ¨κΉ
|
31 |
+
selected_menu = st.sidebar.selectbox("Menu", list(menus.keys()), key='main_menu')
|
32 |
st.session_state['current_menu'] = selected_menu
|
33 |
|
|
|
|
|
34 |
# νμ λ©λ΄ μ ν (ν΄λΉλλ κ²½μ°)
|
35 |
if selected_menu in menus:
|
36 |
+
# `key` μΈμμ `selected_menu` κ°μ μ¬μ©νμ¬ κ³ μ ν ν€λ₯Ό μμ±
|
37 |
+
selected_sub_menu = st.sidebar.selectbox("Sub Menu", [""] + menus[selected_menu], key=f'sub_menu_{selected_menu}')
|
38 |
st.session_state['current_sub_menu'] = selected_sub_menu
|
39 |
else:
|
40 |
st.session_state['current_sub_menu'] = ''
|
41 |
|
42 |
+
|
43 |
+
|
44 |
# μ¬κΈ°μλΆν° `selected_menu` λ³μλ₯Ό κΈ°λ°μΌλ‘ 쑰건문μ μ¬μ©νλ λλ¨Έμ§ μ½λκ° μ¬λ°λ₯΄κ² μλν κ²μ
λλ€.
|
45 |
|
46 |
# Pexels API ν€ μ€μ
|
|
|
88 |
with cols[idx % 3]:
|
89 |
st.video(video)
|
90 |
|
91 |
+
# 'Image' λ©λ΄μμ 'Remove Background' μ ν μ
|
92 |
+
if selected_menu == "Image" and st.session_state['current_sub_menu'] == "Remove Background":
|
93 |
+
st.header("Remove Background")
|
94 |
+
# iframeμ μ¬μ©νμ¬ μΈλΆ URL μλ² λ
|
95 |
+
components.iframe("https://seawolf2357-gttstest.hf.space", width=None, height=600, scrolling=True)
|
96 |
+
|
97 |
|
98 |
+
# 'Sound' λ©λ΄μ 'TTS(Voice)' μ ν μ
|
99 |
+
if st.sidebar.selectbox("Menu", list(menus.keys())) == "Sound":
|
100 |
+
if st.sidebar.selectbox("Sub Menu", menus["Sound"]) == "TTS(Voice)":
|
101 |
+
st.header("Text-to-Speech")
|
102 |
+
# ν
μ€νΈ μ
λ ₯
|
103 |
+
text = st.text_area("Enter text to synthesize", "Hello, welcome to ViDraft TTS service.")
|
104 |
+
# μΈμ΄ μ ν
|
105 |
+
language = st.selectbox("Choose Language", ["en", "es", "de", "fr", "it", "pt", "ru", "ja", "ko", "zh-cn", "zh-tw"])
|
106 |
+
|
107 |
+
# 'Synthesize' λ²νΌ
|
108 |
+
if st.button("Synthesize"):
|
109 |
+
if text:
|
110 |
+
try:
|
111 |
+
tts = gTTS(text=text, lang=language, slow=False)
|
112 |
+
audio_file = BytesIO()
|
113 |
+
tts.write_to_fp(audio_file)
|
114 |
+
audio_file.seek(0)
|
115 |
+
st.audio(audio_file, format='audio/mp3')
|
116 |
+
except Exception as e:
|
117 |
+
st.error(f"Error: {e}")
|
118 |
+
else:
|
119 |
+
st.warning("Please enter some text to synthesize.")
|
120 |
+
|
121 |
+
|
122 |
# 'Home' νμ΄μ§ νμ
|
123 |
if selected_menu == "Home":
|
124 |
st.header("Welcome to ViDraft")
|
|
|
148 |
elif st.session_state['current_sub_menu'] == "Inpainting":
|
149 |
st.header("Inpainting")
|
150 |
st.write("Fill in missing parts of images.")
|
151 |
+
|
|
|
|
|
152 |
elif st.session_state['current_sub_menu'] == "Studio":
|
153 |
st.header("Image Studio")
|
154 |
st.write("Access a suite of image editing tools.")
|
|
|
176 |
elif st.session_state['current_sub_menu'] == "Video Music":
|
177 |
st.header("Video Music")
|
178 |
st.write("Find the perfect music for your video content.")
|
|
|
|
|
|
|
179 |
elif st.session_state['current_sub_menu'] == "Image SFX":
|
180 |
st.header("Image Sound Effects")
|
181 |
st.write("Add sound effects to your images.")
|