Spaces:
Runtime error
Runtime error
# Utils | |
import os | |
import soundfile as sf | |
# Streamlit | |
import streamlit as st | |
# Custom elements | |
from elements.component import ( | |
centered_text, | |
) | |
from elements.session_states import ( | |
init_session_state, | |
update_session_state, | |
update_model, | |
) | |
from elements.tts import ( | |
generate_voice, | |
) | |
st.set_page_config( | |
page_title = "Nix-TTS Interactive Demo", | |
page_icon = "π€", | |
) | |
# Initiate stuffs | |
init_session_state() | |
# --------------------------------------------------------------------------------- | |
# Description | |
centered_text("π€ Nix-TTS Interactive Demo") | |
centered_text("An incredibly lightweight end-to-end text-to-speech model via knowledge distillation", "h5") | |
st.write(" ") | |
st.caption("ποΈ This is a demo from our latest paper, **Nix-TTS**. <br> You can access the paper and the released models [here](https://github.com/rendchevi/nix-tts). <br> Authors: Rendi Chevi, Radityo Eko Prasojo, Alham Fikri Aji.<br> **Corresponding Author**: Rendi Chevi | rendi.chevi@{kata.ai, gmail.com}.", True) | |
# Model demo | |
st.write(" ") | |
st.write(" ") | |
col1, col2 = st.columns(2) | |
with col1: | |
input_text = st.text_input( | |
"Input Text", | |
value = "Born to multiply, born to gaze into night skies.", | |
) | |
with col2: | |
model_variant = st.selectbox("Choose Model Variant", options = ["Deterministic", "Stochastic"], index = 1) | |
if model_variant != st.session_state.model_variant: | |
# Update variant choice | |
update_session_state("model_variant", model_variant) | |
# Re-load model | |
update_model() | |
button_gen = st.button("Generate Voice") | |
if button_gen == True: | |
generate_voice(input_text) | |