AI 음성 복제
Instant voice cloning by MyShell.
https://github.com/myshell-ai/OpenVoice
//-------------------------------------
< 설치 ( linux, wsl ubuntu ) >
$ conda create -n openvoice python=3.9
$ conda activate openvoice
$ git clone https://github.com/myshell-ai/OpenVoice
$ cd OpenVoice
$ pip install -e .
- checkpoint 다운로드
$ wget https://myshell-public-repo-hosting.s3.amazonaws.com/openvoice/checkpoints_v2_0417.zip
$ unzip checkpoints_v2_0417.zip
- MeloTTS 설치
$ pip install git+https://github.com/myshell-ai/MeloTTS.git
$ python -m unidic download
//-------------------------------------
추가 설치
$ sudo apt install ffmpeg
https://github.com/SamuraiT/mecab-python3
$ pip install mecab-python3 cutlet unidic-lite unidic
//-------------------------------------
- sample code
https://github.com/myshell-ai/OpenVoice/blob/main/demo_part3.ipynb
import os
import torch
from openvoice import se_extractor
from openvoice.api import ToneColorConverter
# -------------------------------------
ckpt_converter = 'checkpoints_v2/converter'
device = "cuda:0" if torch.cuda.is_available() else "cpu"
output_dir = 'outputs_v2'
tone_color_converter = ToneColorConverter(f'{ckpt_converter}/config.json', device=device)
tone_color_converter.load_ckpt(f'{ckpt_converter}/checkpoint.pth')
os.makedirs(output_dir, exist_ok=True)
# -------------------------------------
reference_speaker = 'resources/example_reference.mp3' # This is the voice you want to clone
reference_speaker = 'resources/chim1.mp3'
target_se, audio_name = se_extractor.get_se(reference_speaker, tone_color_converter, vad=False)
# -------------------------------------
from melo.api import TTS
""" texts = {
'EN_NEWEST': "Did you ever hear a folk tale about a giant turtle?", # The newest English base speaker model
'EN': "Did you ever hear a folk tale about a giant turtle?",
'ES': "El resplandor del sol acaricia las olas, pintando el cielo con una paleta deslumbrante.",
'FR': "La lueur dorée du soleil caresse les vagues, peignant le ciel d'une palette éblouissante.",
'ZH': "在这次vacation中,我们计划去Paris欣赏埃菲尔铁塔和卢浮宫的美景。",
'JP': "彼は毎朝ジョギングをして体を健康に保っています。",
'KR': "안녕하세요! 오늘은 날씨가 정말 좋네요.",
} """
texts = {
'KR': "안녕하세요! 오늘은 날씨가 정말 좋네요.",
}
src_path = f'{output_dir}/tmp.wav'
# Speed is adjustable
speed = 1.0
for language, text in texts.items():
model = TTS(language=language, device=device)
speaker_ids = model.hps.data.spk2id
for speaker_key in speaker_ids.keys():
speaker_id = speaker_ids[speaker_key]
speaker_key = speaker_key.lower().replace('_', '-')
source_se = torch.load(f'checkpoints_v2/base_speakers/ses/{speaker_key}.pth', map_location=device)
model.tts_to_file(text, speaker_id, src_path, speed=speed)
save_path = f'{output_dir}/output_v2_{speaker_key}.wav'
# Run the tone color converter
encode_message = "@MyShell"
tone_color_converter.convert(
audio_src_path=src_path,
src_se=source_se,
tgt_se=target_se,
output_path=save_path,
message=encode_message)
//-----------------------------------------------------------------------------
에러 처리
//-------------------------------------
- 에러 메시지
[ifs] no such file or directory: /home/ubuntu/anaconda3/envs/openvoice/lib/python3.9/site-packages/unidic/dicdir/mecabrc
- 해결방법1
$ python -m unidic download
- 해결방법2 : unidic_lite 의 dicdir 을 unidic 폴더에 복사
$ cp /home/ubuntu/anaconda3/envs/openvoice/lib/python3.9/site-packages/unidic_lite/dicdir /home/ubuntu/anaconda3/envs/openvoice/lib/python3.9/site-packages/unidic
//-------------------------------------
- 에러 메시지
Could not load library libcudnn_cnn_infer.so.8. Error: libcudnn_cnn_infer.so.8: cannot open shared object file: No such file or directory
Please make sure libcudnn_cnn_infer.so.8 is in your library path!
- 해결방법 : cuDNN 설치하거나 libcudnn_cnn_infer.so.8 파일이 있는데도 에러가 난다면 해당 경로 환경 설정
https://codens.tistory.com/2784
libcudnn_cnn_infer.so.8 파일이 있는 경로가 가 /nvidia/cudnn/lib 인 경우
$ export LD_LIBRARY_PATH=/nvidia/cudnn/lib:$LD_LIBRARY_PATH
'AI' 카테고리의 다른 글
AI 모델의 버전별 출시일 (0) | 2024.05.01 |
---|---|
리눅스(WSL Ubuntu)에서 CUDA, cuDNN 설치하는 방법 (0) | 2024.04.30 |
huggingface 사용법 (인증, 다운로드 방법) (0) | 2024.04.28 |
WebUI for LLMs (Ollama WebUI) 사용법 (0) | 2024.04.23 |
Real-Time-Voice-Cloning 사용방법 (0) | 2024.04.19 |