File size: 923 Bytes
2ce9600
d04894f
 
569b020
 
2ce9600
 
 
 
 
 
 
 
569b020
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2ce9600
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
import streamlit as st
from transformers import pipeline

# Initialize text-to-speech model (small lightweight model)
tts_model = pipeline("text-to-speech", model="espnet/kan-bayashi_ljspeech_vits")

# Streamlit app UI
st.title("Text-to-Audio App")
st.text("This app generates audio from text input using Hugging Face models.")

# User input
text_input = st.text_area("Enter some text for the model:")

if st.button("Generate Audio"):
    if not text_input.strip():
        st.error("Please enter some text!")
    else:
        # Generate response
        st.text("Generating audio response...")
        tts_audio = tts_model(text_input)

        # Save the audio output
        audio_file = "response.wav"
        with open(audio_file, "wb") as f:
            f.write(tts_audio["wav"])

        # Display audio response
        st.audio(audio_file, format="audio/wav")
        st.success("Audio generated successfully!")