|
import torch |
|
from TTS.api import TTS |
|
import gradio as gr |
|
device="cuda" if torch.cuda.is_available() else "cpu" |
|
|
|
tts=TTS(model_name="voice_conversion_models/multilingual/vctk/freevc24",progress_bar=False).to(device) |
|
path="output.wav" |
|
target_voice="" |
|
source_voice="" |
|
def VoiceClone(source_Uvoice,source_Mvoice,Target_UVoice,Target_MVoive): |
|
if source_Uvoice is not None: |
|
source_voice=source_Uvoice |
|
elif source_Mvoice is not None: |
|
source_voice=source_Mvoice |
|
if Target_UVoice is not None: |
|
target_voice=Target_UVoice |
|
elif Target_MVoive is not None: |
|
target_voice=Target_MVoive |
|
return tts.voice_conversion_to_file(source_wav=source_voice, target_wav=target_voice, file_path=path) |
|
|
|
|
|
interface=gr.Interface(fn=VoiceClone,inputs=[gr.Audio(type="filepath", sources="upload",label='Please upload a source voice'),gr.Audio(sources="microphone", type="filepath", streaming=True),gr.Audio(type="filepath", sources="upload",label='Please upload Target Voice'),gr.Audio(sources="microphone", type="filepath", streaming=True)], |
|
outputs=[gr.Audio(type="filepath")], |
|
title="Abdul Rehman Voice Cloning and Conversion Tool", |
|
description="Change your voice into Target voice tone") |
|
interface.launch(debug=True) |