make the python script a gradio script that allows for selection of voice and text to…
- User
make the python script a gradio script that allows for selection of voice and text to type also allow the model inference to be better like keep the model loaded until the program exits that way inference is fast and stuff please return entire script fixed
import os from huggingface_hub import snapshot_download
from models.vc.vevo.vevo_utils import *
def vevo_tts( src_text, ref_wav_path, timbre_ref_wav_path=None, output_path=None, ref_text=None, src_language="en", ref_language="en", ): if timbre_ref_wav_path is None: timbre_ref_wav_path = ref_wav_path
gen_audio = inference_pipeline.inference_ar_and_fm( src_wav_path=None, src_text=src_text, style_ref_wav_path=ref_wav_path, timbre_ref_wav_path=timbre_ref_wav_path, style_ref_wav_text=ref_text, src_text_language=src_language, style_ref_wav_text_language=ref_language, ) assert output_path is not None save_audio(gen_audio, output_path=output_path)if name == "main": # ===== Device ===== device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
# ===== Content-Style Tokenizer ===== local_dir = snapshot_download( repo_id="amphion/Vevo", repo_type="model", cache_dir="./ckpts/Vevo", allow_patterns=["tokenizer/vq8192/*"], ) content_style_tokenizer_ckpt_path = os.path.join(local_dir, "tokenizer/vq8192") # ===== Autoregressive Transformer ===== local_dir = snapshot_download( repo_id="amphion/Vevo", repo_type="model", cache_dir="./ckpts/Vevo", allow_patterns=["contentstyle_modeling/PhoneToVq8192/*"], ) ar_cfg_path = "./models/vc/vevo/config/PhoneToVq8192.json" ar_ckpt_path = os.path.join(local_dir, "contentstyle_modeling/PhoneToVq8192") # ===== Flow Matching Transformer ===== local_dir = snapshot_download( repo_id="amphion/Vevo", repo_type="model", cache_dir="./ckpts/Vevo", allow_patterns=["acoustic_modeling/Vq8192ToMels/*"], ) fmt_cfg_path = "./models/vc/vevo/config/Vq8192ToMels.json" fmt_ckpt_path = os.path.join(local_dir, "acoustic_modeling/Vq8192ToMels") # ===== Vocoder ===== local_dir = snapshot_download( repo_id="amphion/Vevo", repo_type="model", cache_dir="./ckpts/Vevo", allow_patterns=["acoustic_modeling/Vocoder/*"], ) vocoder_cfg_path = "./models/vc/vevo/config/Vocoder.json" vocoder_ckpt_path = os.path.join(local_dir, "acoustic_modeling/Vocoder") # ===== Inference ===== inference_pipeline = VevoInferencePipeline( content_style_tokenizer_ckpt_path=content_style_tokenizer_ckpt_path, ar_cfg_path=ar_cfg_path, ar_ckpt_path=ar_ckpt_path, fmt_cfg_path=fmt_cfg_path, fmt_ckpt_path=fmt_ckpt_path, vocoder_cfg_path=vocoder_cfg_path, vocoder_ckpt_path=vocoder_ckpt_path, device=device, ) src_text = "I don't really care what you call me. I've been a silent spectator, watching species evolve, empires rise and fall. But always remember, I am mighty and enduring. Respect me and I'll nurture you; ignore me and you shall face the consequences." ref_wav_path = "./models/vc/vevo/wav/arabic_male.wav" ref_text = "Flip stood undecided, his ears strained to catch the slightest sound." # 1. Zero-Shot TTS (the style reference and timbre reference are same) vevo_tts( src_text, ref_wav_path, output_path="./models/vc/vevo/wav/output_vevotts1.wav", ref_text=ref_text, src_language="en", ref_language="en", ) # 2. Style and Timbre Controllable Zero-Shot TTS (the style reference and timbre reference are different) vevo_tts( src_text, ref_wav_path, timbre_ref_wav_path="./models/vc/vevo/wav/mandarin_female.wav", output_path="./models/vc/vevo/wav/output_vevotts2.wav", ref_text=ref_text, src_language="en", ref_language="en", ) - Assistant
- User
ok cool but I want the selected voice to be an audio file input not a radio button. fix and return full script
- Assistant
- User
Traceback (most recent call last): File "/home/meow/anaconda3/envs/vevo/lib/python3.10/runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "/home/meow/anaconda3/envs/vevo/lib/python3.10/runpy.py", line 86, in _run_code exec(code, run_globals) File "/home/meow/Amphion/models/vc/vevo/infer_vevotts.py", line 115, in voice_upload = gr.Audio( File "/home/meow/anaconda3/envs/vevo/lib/python3.10/site-packages/gradio/component_meta.py", line 185, in wrapper return fn(self, **kwargs) TypeError: Audio.init() got an unexpected keyword argument 'source'
fix and return entire code.
- Assistant
- User
(vevo) meow@Anbernic-Win600:~/Amphion python -m models.vc.vevo.infer_vevotts Fetching 1 files: 100%|████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 27594.11it/s] Fetching 1 files: 100%|████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 12372.58it/s] Fetching 1 files: 100%|█████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 4161.02it/s] Fetching 3 files: 100%|████████████████████████████████████████████████████████████████| 3/3 [00:00<00:00, 81180.08it/s] #Params of AR model: 743.30 M #Params of Flow Matching model: 337.69 M #Params of Vocoder model: 255.04 M #Params of Content-Style Tokenizer: 44.29 M Traceback (most recent call last): File "/home/meow/anaconda3/envs/vevo/lib/python3.10/runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "/home/meow/anaconda3/envs/vevo/lib/python3.10/runpy.py", line 86, in _run_code exec(code, run_globals) File "/home/meow/Amphion/models/vc/vevo/infer_vevotts.py", line 115, in <module> voice_upload = gr.Audio( File "/home/meow/anaconda3/envs/vevo/lib/python3.10/site-packages/gradio/component_meta.py", line 185, in wrapper return fn(self, **kwargs) TypeError: Audio.__init__() got an unexpected keyword argument 'file_types' (vevo) meow@Anbernic-Win600:~/Amphion
- Assistant
- User
its saying
(vevo) meow@Anbernic-Win600:~/Amphion$ python -m models.vc.vevo.infer_vevotts Fetching 1 files: 100%|████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 27776.85it/s] Fetching 1 files: 100%|█████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 2245.34it/s] Fetching 1 files: 100%|████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 11650.84it/s] Fetching 3 files: 100%|████████████████████████████████████████████████████████████████| 3/3 [00:00<00:00, 26105.63it/s] #Params of AR model: 743.30 M #Params of Flow Matching model: 337.69 M #Params of Vocoder model: 255.04 M #Params of Content-Style Tokenizer: 44.29 M
- Running on local URL: http://127.0.0.1:7860
- To create a public link, set
share=Trueinlaunch(). /home/meow/Amphion/models/vc/vevo/vevo_utils.py:141: UserWarning: PySoundFile failed. Trying audioread instead. speech = librosa.load(wav_path, sr=24000)[0] /home/meow/anaconda3/envs/vevo/lib/python3.10/site-packages/librosa/core/audio.py:184: FutureWarning: librosa.core.audio.__audioread_load Deprecated as of librosa version 0.10.0. It will be removed in librosa version 1.0. y, sr_native = __audioread_load(path, offset, duration, dtype)
- Assistant