-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctional.py
More file actions
41 lines (36 loc) · 967 Bytes
/
Copy pathfunctional.py
File metadata and controls
41 lines (36 loc) · 967 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import os
import torch
import librosa
import json
from tqdm import tqdm
from scipy.io import wavfile
import utils
from mel_processing import mel_spectrogram_torch
from wavlm import WavLM, WavLMConfig
from transformers import Wav2Vec2Processor, HubertForCTC
import os
from glob import glob
from jiwer import wer, cer
import re
from tqdm import tqdm
import numpy as np
import random
import hifigan
import soundfile as sf
def seed_everything(SEED):
np.random.seed(SEED)
torch.manual_seed(SEED)
torch.cuda.manual_seed(SEED)
torch.backends.cudnn.deterministic = True
seed_everything(0)
def get_vocoder(rank):
with open("hifigan/config.json", "r") as f:
config = json.load(f)
config = hifigan.AttrDict(config)
vocoder = hifigan.Generator(config)
ckpt = torch.load("hifigan/generator_v1")
vocoder.load_state_dict(ckpt["generator"])
vocoder.eval()
vocoder.remove_weight_norm()
vocoder.cuda(rank)
return vocoder