RVC(Retrieval-based-Voice-Conversion)のモデルを使ってpythonのプログラムを自分で作る

2024年4月1日

準備

コード

from pathlib import Path

from dotenv import load_dotenv
import soundfile as sf

from infer.modules.vc.modules import VC
import os
from os.path import join, dirname
from configs.config import Config

def main():

      config = Config()
      vc = VC(config)
      vc.get_vc("kikiV1.pth")
      _,tgt_opt = vc.vc_single(
        1, 
        "prec.wav",
        f0_up_key = 0,
        f0_method = "rmvpe",
        f0_file = None,
        file_index = None,
        file_index2 = None,
        index_rate = 0.75,
        filter_radius = 3,
        resample_sr = 0,
        rms_mix_rate = 0.25,
        protect= 0.33,
      )
      tgt_sr, audio_opt = tgt_opt
      sf.write("generation.wav",audio_opt , tgt_sr)

if __name__ == "__main__":
#      load_dotenv(verbose=True)
      dotenv_path = join(dirname(__file__), '.env')
      print(f"wav '{dotenv_path}' generated successfully!")
      load_dotenv(dotenv_path)
#      load_dotenv(".env")
      main()

Python

Posted by eightban