Wiki source code of Install OpenVoice v2 Locally - Instantly Clone Voice with AI
Last modified by René Schmidt on 2025/03/26 14:55
Hide last authors
| author | version | line-number | content |
|---|---|---|---|
![]() |
2.6 | 1 | conda create -n openvoice python=3.9 |
![]() |
2.1 | 2 | conda activate openvoice |
| 3 | |||
| 4 | |||
![]() |
2.6 | 5 | git clone [[https:~~/~~/github.com/myshell-ai/openVoice.git>>https://github.com/myshell-ai/openVoice.git]] |
![]() |
2.1 | 6 | |
| 7 | cd openVoice | ||
| 8 | pip install -e . | ||
| 9 | mkdir checkpoints_v2 | ||
| 10 | cd checkpoints_v2 | ||
| 11 | wget [[https:~~/~~/myshell-public-repo-host.s3.amazonaws.com/openvoice/checkpoints_v2_0417.zip>>https://myshell-public-repo-host.s3.amazonaws.com/openvoice/checkpoints_v2_0417.zip]] | ||
| 12 | |||
| 13 | unzip checkpoints_v2_0417.zip | ||
| 14 | |||
| 15 | |||
![]() |
2.6 | 16 | mv checkpoints_v2 ~~/OpenVoice |
![]() |
2.1 | 17 | |
![]() |
4.1 | 18 | cd .. |
![]() |
2.1 | 19 | |
| 20 | |||
| 21 | |||
| 22 | |||
| 23 | |||
![]() |
4.1 | 24 | |
![]() |
2.1 | 25 | pip install git+https:~/~/github.com/cocktailpeanut/ov2.git |
| 26 | |||
| 27 | |||
| 28 | |||
| 29 | cd .. | ||
| 30 | pip install git+https:~/~/github.com/myshell-ai/MeloTTS.git | ||
| 31 | python -m unidic download | ||
| 32 | cd resources | ||
| 33 | python3 | ||
| 34 | |||
| 35 | |||
| 36 | |||
![]() |
1.1 | 37 | import os |
| 38 | |||
| 39 | import torch | ||
| 40 | |||
| 41 | from openvoice import se_extractor | ||
| 42 | |||
| 43 | from openvoice.api import ToneColorConverter | ||
| 44 | |||
| 45 | ckpt_converter = 'checkpoints_v2/converter' | ||
| 46 | |||
| 47 | device = "cuda:0" if torch.cuda.is_available() else "cpu" | ||
| 48 | |||
| 49 | output_dir = 'outputs_v2' | ||
| 50 | |||
![]() |
2.6 | 51 | tone_color_converter = ToneColorConverter(f' {ckpt_converter} /config.json', device=device) |
![]() |
2.3 | 52 | |
| 53 | tone_color_converter.load_ckpt(f' {ckpt_converter} /checkpoint.pth') | ||
| 54 | |||
| 55 | os.makedirs (output_dir, exist_ok=True) | ||
| 56 | |||
| 57 | reference_speaker = 'resources/example_reference.mp3' | ||
| 58 | |||
![]() |
2.4 | 59 | target_se, audio_name = se_extractor.get_se(reference_speaker, tone_color_converter, vad=False) |
| 60 | |||
| 61 | from melo.api import TTS | ||
| 62 | |||
| 63 | src_path = f' {output_dir} /tmp.wav' | ||
| 64 | |||
| 65 | speed = 1.0 | ||
| 66 | |||
| 67 | |||
| 68 | |||
| 69 | |||
![]() |
2.3 | 70 |
