File size: 2,237 Bytes
04f5f15
27e120f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8bd7fcb
27e120f
 
 
 
 
 
 
 
 
 
 
 
 
 
8bd7fcb
27e120f
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
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
41
42
43
44
45
46
47
48
49
import streamlit as st
import requests
import json
import base64
import io
import tempfile
from streamlit_lottie import st_lottie, st_lottie_spinner
import streamlit.components.v1 as st1
import time

def load_local_lottie(path):
    with open(path, 'r') as file:
        return json.load(file)

# βœ… Only initialize the state if not already set
if "loading_state" not in st.session_state:
    st.session_state.loading_state = True

# βœ… Show loading animation only once at first load
if st.session_state.loading_state:
    with st_lottie_spinner(load_local_lottie('./src/Loading.json'), key='hello'):
        time.sleep(3)
    st.session_state.loading_state = False

# βœ… App main UI
st.title("Welcome to Spark Anime TTS Demo website.")
st.markdown("#### This model is fined tuned on Spark TTS model and fined tuned on the AnimeVox dataset. (Stay tuned with demo chatbot)")
text = st.text_area("Enter text to convert to speech:")
character = st.selectbox("Select Character", [
    'Power', 'Asuna Yuuki', 'Shiro', 'Frieren', 'Mai Sakurajima', 'Megumin', 'Fern',
    'Madoka Kaname', 'Homura Akemi', 'Momo Ayase', 'Mikasa Ackerman', 'Saber',
    'Rin Tohsaka', 'Rem', 'Kurisu Makise', 'Lucy', 'Marin Kitagawa', 'Emilia', 'Makima'
])

if st.button("Play Audio"):
    with st_lottie_spinner(load_local_lottie('./src/voiceline.json'), key='download'):
        url = "https://8000-01jynw0agcdpzps7kn9c8gfs4p.cloudspaces.litng.ai/predict"
        data = {"prompt": text, "charecter": character}
        response = requests.post(url, json=data)
        audio_data = response.json()['audio']
        audio_bytes = base64.b64decode(audio_data)
        with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as temp_file:
            temp_file.write(audio_bytes)
            temp_file_path = temp_file.name
    st.audio(temp_file_path, format="audio/mp3")
st1.iframe("https://cloudhand-sdk-alecbidarans-projects.vercel.app/",height=200)
st1.iframe("""
<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>
          """,height=200)