|
import torch |
|
from dreamvoice import DreamVoice_Plugin |
|
from dreamvoice.openvoice_utils import se_extractor |
|
from openvoice.api import ToneColorConverter |
|
|
|
|
|
|
|
dreamvoice = DreamVoice_Plugin(device='cuda') |
|
|
|
|
|
ckpt_converter = 'checkpoints_v2/converter' |
|
device = "cuda:0" if torch.cuda.is_available() else "cpu" |
|
openvoice = ToneColorConverter(f'{ckpt_converter}/config.json', device=device) |
|
openvoice.load_ckpt(f'{ckpt_converter}/checkpoint.pth') |
|
|
|
|
|
prompt = 'female voice, bright and cute' |
|
target_se = dreamvoice.gen_spk(prompt) |
|
target_se = target_se.unsqueeze(-1) |
|
|
|
|
|
source_path = 'segment_1.mp3' |
|
source_se = se_extractor(source_path, openvoice).to(device) |
|
|
|
|
|
encode_message = "@MyShell" |
|
openvoice.convert( |
|
audio_src_path=source_path, |
|
src_se=source_se, |
|
tgt_se=target_se, |
|
output_path='output.wav', |
|
message=encode_message) |