File size: 1,026 Bytes
812ef64
a7ad758
 
812ef64
58cbd5a
 
a7ad758
 
 
 
812ef64
 
 
58cbd5a
 
812ef64
a7ad758
 
 
98cf224
812ef64
 
a7ad758
812ef64
 
 
a7ad758
812ef64
98cf224
812ef64
 
 
 
a7ad758
 
812ef64
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
import streamlit as st
import torch
from TTS.api import TTS

# Set Page Title
st.title("Text to Speech with Overflow")
# Get device
device = "cuda" if torch.cuda.is_available() else "cpu"
# Init TTS
tts = TTS("tts_models/en/ljspeech/overflow").to(device)

# Input form for the user to enter text
user_input = st.text_area("Enter the text:")

if st.button("Synthesize"):
    if user_input:
        # audio = text_to_audio(user_input)
        
        # Text to speech to a file
        tts.tts_to_file(text=user_input, file_path="output.wav")

        # Display the audio
        st.audio("output.wav", format="audio/wav")

        # Create a download link for the audio file
        st.markdown("### Download the audio")
        with open("output.wav", "rb") as audio_file:
            audio_bytes = audio_file.read()

        st.download_button(
            label="Click to download",
            data=audio_bytes,
            key="download_audio",
            file_name="output.wav",
            mime="audio/wav",
        )