alibidaran commited on
Commit
27e120f
Β·
verified Β·
1 Parent(s): 033ed2d

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. 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
- # Welcome to Streamlit!
8
-
9
- Edit `/streamlit_app.py` to customize this app to your heart's desire :heart:.
10
- If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
11
- forums](https://discuss.streamlit.io).
12
-
13
- In the meantime, below is an example of what you can do with just a few lines of code:
14
- """
15
-
16
- num_points = st.slider("Number of points in spiral", 1, 10000, 1100)
17
- num_turns = st.slider("Number of turns in spiral", 1, 300, 31)
18
-
19
- indices = np.linspace(0, 1, num_points)
20
- theta = 2 * np.pi * num_turns * indices
21
- radius = indices
22
-
23
- x = radius * np.cos(theta)
24
- y = radius * np.sin(theta)
25
-
26
- df = pd.DataFrame({
27
- "x": x,
28
- "y": y,
29
- "idx": indices,
30
- "rand": np.random.randn(num_points),
31
- })
32
-
33
- st.altair_chart(alt.Chart(df, height=700, width=700)
34
- .mark_point(filled=True)
35
- .encode(
36
- x=alt.X("x", axis=None),
37
- y=alt.Y("y", axis=None),
38
- color=alt.Color("idx", legend=None, scale=alt.Scale()),
39
- size=alt.Size("rand", legend=None, scale=alt.Scale(range=[1, 150])),
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)