from huggingface_hub import snapshot_download
from malaya_speech.torch_model.vits.model_infer import SynthesizerTrn
from malaya_speech.torch_model.vits.commons import intersperse
from malaya_speech.utils.text import TTS_SYMBOLS
from malaya_speech.tts import load_text_ids
import torch
import os
import json
try:
from malaya_boilerplate.hparams import HParams
except BaseException:
from malaya_boilerplate.train.config import HParams
speaker_id = {
'Husein': 0,
'Shafiqah Idayu': 1,
'Anwar Ibrahim': 2,
}
folder = snapshot_download(repo_id="mesolitica/VITS-multispeaker-clean-v2")
withopen(os.path.join(folder, 'config.json')) as fopen:
hps = HParams(**json.load(fopen))
model = SynthesizerTrn(
len(TTS_SYMBOLS),
hps.data.filter_length // 2 + 1,
hps.train.segment_size // hps.data.hop_length,
n_speakers=hps.data.n_speakers,
**hps.model,
).eval()
model.load_state_dict(torch.load(os.path.join(folder, 'model.pth'), map_location='cpu'))
normalizer = load_text_ids(pad_to = None, understand_punct = True, is_lower = False)
t, ids = normalizer.normalize('saya nak makan nasi ayam yang sedap, lagi lazat, dan hidup sangatlah susah kan.', add_fullstop = False)
if hps.data.add_blank:
ids = intersperse(ids, 0)
ids = torch.LongTensor(ids)
ids_lengths = torch.LongTensor([ids.size(0)])
ids = ids.unsqueeze(0)
sid = torch.tensor([speaker_id['Husein']])
with torch.no_grad():
audio = model.infer(
ids,
ids_lengths,
noise_scale=0.0,
noise_scale_w=0.0,
length_scale=1.0,
sid=sid,
)
y_ = audio[0].numpy()
Runs of malaysia-ai malay-VITS-multispeaker on huggingface.co
91
Total runs
0
24-hour runs
0
3-day runs
0
7-day runs
0
30-day runs
More Information About malay-VITS-multispeaker huggingface.co Model
malay-VITS-multispeaker huggingface.co
malay-VITS-multispeaker huggingface.co is an AI model on huggingface.co that provides malay-VITS-multispeaker's model effect (), which can be used instantly with this malaysia-ai malay-VITS-multispeaker model. huggingface.co supports a free trial of the malay-VITS-multispeaker model, and also provides paid use of the malay-VITS-multispeaker. Support call malay-VITS-multispeaker model through api, including Node.js, Python, http.
malay-VITS-multispeaker huggingface.co is an online trial and call api platform, which integrates malay-VITS-multispeaker's modeling effects, including api services, and provides a free online trial of malay-VITS-multispeaker, you can try malay-VITS-multispeaker online for free by clicking the link below.
malaysia-ai malay-VITS-multispeaker online free url in huggingface.co:
malay-VITS-multispeaker is an open source model from GitHub that offers a free installation service, and any user can find malay-VITS-multispeaker on GitHub to install. At the same time, huggingface.co provides the effect of malay-VITS-multispeaker install, users can directly use malay-VITS-multispeaker installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
malay-VITS-multispeaker install url in huggingface.co: