| import gradio as gr |
| import os |
| |
| |
| os.system('/usr/local/bin/python -m pip install --upgrade pip') |
| os.system("pip install git+https://github.com/allthingssecurity/vall-e/") |
| os.system("pip install pydub") |
| from pydub import AudioSegment |
| import tempfile |
|
|
| def synthesis(audio_file: tempfile._TemporaryFileWrapper, text: str, ar_ckpt: str, nar_ckpt: str): |
| |
| audio = AudioSegment.from_file(audio_file) |
| |
| temp_file = "temp.wav" |
| audio.export(temp_file, format="wav") |
| |
| output_file = "output.wav" |
| vall_e.synthesis(text, temp_file, output_file, ar_ckpt=ar_ckpt, nar_ckpt=nar_ckpt) |
| |
| output_audio = AudioSegment.from_file(output_file) |
| return output_audio |
|
|
| synthesis_interface = gr.Interface(synthesis, |
| inputs={"audio_file": gr.File(file_count="multiple"), "text": "text", "ar_ckpt": "text", "nar_ckpt": "text"}, |
| live=True, |
| capture_session=True,outputs="audio") |
| synthesis_interface.launch() |