Downloads · 30 days
0
HyunaZ/vits-kor-emotion
vits-kor-emotion is a machine learning model from HyunaZ. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
license: cc-by-nc-4.0 tags: - mms - vits pipelinetag: text-to-speech
Downloads · 30 days
0
Access
Public
Updated Dec 19, 2024
Repo size
146 MB
Likes
2
Public
Click a slice to open those files.
.pth146 MB · 100%
From the Hugging Face model README
license: cc-by-nc-4.0 tags:
facebook/mms-tts-kor 를 베이스모델로 활용했습니다.
import torch
import soundfile as sf
from transformers import VitsModel, AutoTokenizer
import sys
sys.path.append('/home/user/AZ/tts_emotion')
from train import EmotionalVitsModel # train.py에서 모델 import
def inference_emotional_tts(checkpoint_path, text="안녕하세요", emotion=0, output_path="output.wav"):
# 모델 초기화
model = EmotionalVitsModel()
checkpoint = torch.load(checkpoint_path)
model.load_state_dict(checkpoint['model_state_dict'])
model.cuda()
model.eval()
# 토크나이저
tokenizer = AutoTokenizer.from_pretrained("facebook/mms-tts-kor")
text_tokens = tokenizer(text, return_tensors="pt")
# 추론
with torch.no_grad():
output = model(
input_ids=text_tokens['input_ids'].cuda(),
attention_mask=text_tokens['attention_mask'].cuda(),
emotion=torch.tensor([emotion]).cuda()
)
# waveform을 CPU로 이동하고 numpy로 변환
audio = output.waveform.cpu().numpy()[0, 0]
# wav 파일로 저장 (샘플레이트는 VITS 모델의 기본값인 22050Hz 사용)
sf.write(output_path, audio, 22050)
return output_path
inference_emotional_tts('', #체크포인트 경로
text="안녕하세요 저는 차비스입니다.",
emotion=2, # 0: neutral, 1: happy, 2: sad
output_path="IamChavis.wav")
해당 모델은 AI hub의 감정 음성 합성 데이터셋 (https://www.aihub.or.kr/aihubdata/data/view.do?currMenu=120&topMenu=100&aihubDataSe=extrldata&dataSetSn=286) 중 중립/긍정/부정 데이터셋 각 1000개, 총 3000개를 활용해 학습을 진행했습니다.
기존에 한국어로 사전학습된 파라미터는 고정한 채 감정 레이어만 업데이트 하여 기존 한국어 능력은 유지한 채 감정표현 능력만을 개선했습니다.
| Hyperparameter | Base |
|---|---|
| Learning Rates | 1e-4 |
| Batch Size | 128 |
| padding | segment_length(68608)에 맞춰 오디오 길이 조정 (길면 중앙 부분 추출, 짧으면 0패딩) |
| Optimizer | AdamW |
| Epoch | 30 |