File size: 985 Bytes
81378a3
 
ef8faa8
81378a3
 
 
 
 
7882a3f
99e85e0
81378a3
 
52d0203
6a028f1
52d0203
 
 
 
ae03760
81378a3
 
 
 
 
 
 
 
 
 
 
 
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
import torch 
from TTS.api import TTS
import os 
os.environ["COQUI_TOS_AGREED"] = "1"

device = "cpu"

audio_file_path = "abby_cadabby.wav"

tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to(device)

# Define the function to generate the audio
def clone(text, audio_path=audio_file_path):
    # Ensure the audio_path is correct and the file exists at that location
    if not os.path.isfile(audio_path):
        st.error(f"Audio file not found at {audio_path}")
        return
    tts.tts_to_file(text=text, speaker_wav=audio_path, language="en",split_sentences=True, file_path="./output.wav")
    return "./output.wav"

st.title('Abby Cadabby Voice Clone')
st.write("""Abby Cadabby voice clone using coqui-TTS.
                        Please ✨ this Space.
                        """)

text = st.text_input('Text', 'Type in whatever you would like me to say.')

if st.button('Generate Audio'):
    audio_file = clone(text)
    st.audio(audio_file)