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) |