Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +48 -39
src/streamlit_app.py
CHANGED
@@ -1,40 +1,49 @@
|
|
1 |
-
import altair as alt
|
2 |
-
import numpy as np
|
3 |
-
import pandas as pd
|
4 |
import streamlit as st
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
+
import requests
|
3 |
+
import json
|
4 |
+
import base64
|
5 |
+
import io
|
6 |
+
import tempfile
|
7 |
+
from streamlit_lottie import st_lottie, st_lottie_spinner
|
8 |
+
import streamlit.components.v1 as st1
|
9 |
+
import time
|
10 |
+
|
11 |
+
def load_local_lottie(path):
|
12 |
+
with open(path, 'r') as file:
|
13 |
+
return json.load(file)
|
14 |
+
|
15 |
+
# β
Only initialize the state if not already set
|
16 |
+
if "loading_state" not in st.session_state:
|
17 |
+
st.session_state.loading_state = True
|
18 |
+
|
19 |
+
# β
Show loading animation only once at first load
|
20 |
+
if st.session_state.loading_state:
|
21 |
+
with st_lottie_spinner(load_local_lottie('Loading.json'), key='hello'):
|
22 |
+
time.sleep(3)
|
23 |
+
st.session_state.loading_state = False
|
24 |
+
|
25 |
+
# β
App main UI
|
26 |
+
st.title("Welcome to Spark Anime TTS Demo website.")
|
27 |
+
st.markdown("#### This model is fined tuned on Spark TTS model and fined tuned on the AnimeVox dataset. (Stay tuned with demo chatbot)")
|
28 |
+
text = st.text_area("Enter text to convert to speech:")
|
29 |
+
character = st.selectbox("Select Character", [
|
30 |
+
'Power', 'Asuna Yuuki', 'Shiro', 'Frieren', 'Mai Sakurajima', 'Megumin', 'Fern',
|
31 |
+
'Madoka Kaname', 'Homura Akemi', 'Momo Ayase', 'Mikasa Ackerman', 'Saber',
|
32 |
+
'Rin Tohsaka', 'Rem', 'Kurisu Makise', 'Lucy', 'Marin Kitagawa', 'Emilia', 'Makima'
|
33 |
+
])
|
34 |
+
|
35 |
+
if st.button("Play Audio"):
|
36 |
+
with st_lottie_spinner(load_local_lottie('voiceline.json'), key='download'):
|
37 |
+
url = "https://8000-01jynw0agcdpzps7kn9c8gfs4p.cloudspaces.litng.ai/predict"
|
38 |
+
data = {"prompt": text, "charecter": character}
|
39 |
+
response = requests.post(url, json=data)
|
40 |
+
audio_data = response.json()['audio']
|
41 |
+
audio_bytes = base64.b64decode(audio_data)
|
42 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as temp_file:
|
43 |
+
temp_file.write(audio_bytes)
|
44 |
+
temp_file_path = temp_file.name
|
45 |
+
st.audio(temp_file_path, format="audio/mp3")
|
46 |
+
st1.iframe("https://cloudhand-sdk-alecbidarans-projects.vercel.app/",height=200)
|
47 |
+
st1.iframe("""
|
48 |
+
<a href="https://www.buymeacoffee.com/alibidaran96"><img src="https://img.buymeacoffee.com/button-api/?text=Buy me a coffee&emoji=β&slug=alibidaran96&button_colour=FFDD00&font_colour=000000&font_family=Lato&outline_colour=000000&coffee_colour=ffffff" /></a>
|
49 |
+
""",height=200)
|