File size: 833 Bytes
941f415
33bea70
941f415
 
 
33bea70
 
 
941f415
 
33bea70
 
941f415
 
 
 
 
 
 
 
 
 
 
 
 
365fc27
 
aad4adb
 
 
 
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
import torch
import os
import streamlit as st
from TTS.api import TTS

# By using XTTS you agree to CPML license https://coqui.ai/cpml
os.environ["COQUI_TOS_AGREED"] = "1"

# Initialize model
model = "tts_models/multilingual/multi-dataset/xtts_v2"
device = 'cuda' if torch.cuda.is_available() else 'cpu'
tts = TTS(model).to(device)

# Title
st.title('Voice Cloning')

# Upload audio file
uploaded_file = st.file_uploader('Add an audio file of the voice you want to clone...', type=['wav'])

if uploaded_file:
  st.audio(uploaded_file, format='audio/wav')

  # Input text 
  text_input = st.text_input('Enter the text to synthesize:')

  if text_input:
    if st.button('Synthesize'):
      output_audio = tts.tts_to_file(text=text_input, speaker_wav=uploaded_file, language='en')
  
      st.audio(output_audio, format='audio/wav')