MarcusSu1216 commited on
Commit
e2ce104
1 Parent(s): 842c3cd

Update utils.py

Browse files
Files changed (1) hide show
  1. utils.py +0 -31
utils.py CHANGED
@@ -6,9 +6,7 @@ import argparse
6
  import logging
7
  import json
8
  import subprocess
9
- import warnings
10
  import random
11
- import functools
12
 
13
  import librosa
14
  import numpy as np
@@ -17,8 +15,6 @@ import torch
17
  from torch.nn import functional as F
18
  from modules.commons import sequence_mask
19
  from hubert import hubert_model
20
- from modules.crepe import CrepePitchExtractor
21
-
22
  MATPLOTLIB_FLAG = False
23
 
24
  logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
@@ -50,21 +46,6 @@ f0_mel_max = 1127 * np.log(1 + f0_max / 700)
50
  # factor = torch.ones(f0.shape[0], 1, 1).to(f0.device)
51
  # f0_norm = (f0 - means.unsqueeze(-1)) * factor.unsqueeze(-1)
52
  # return f0_norm
53
-
54
- def deprecated(func):
55
- """This is a decorator which can be used to mark functions
56
- as deprecated. It will result in a warning being emitted
57
- when the function is used."""
58
- @functools.wraps(func)
59
- def new_func(*args, **kwargs):
60
- warnings.simplefilter('always', DeprecationWarning) # turn off filter
61
- warnings.warn("Call to deprecated function {}.".format(func.__name__),
62
- category=DeprecationWarning,
63
- stacklevel=2)
64
- warnings.simplefilter('default', DeprecationWarning) # reset filter
65
- return func(*args, **kwargs)
66
- return new_func
67
-
68
  def normalize_f0(f0, x_mask, uv, random_scale=True):
69
  # calculate means based on x_mask
70
  uv_sum = torch.sum(uv, dim=1, keepdim=True)
@@ -81,18 +62,6 @@ def normalize_f0(f0, x_mask, uv, random_scale=True):
81
  exit(0)
82
  return f0_norm * x_mask
83
 
84
- def compute_f0_uv_torchcrepe(wav_numpy, p_len=None, sampling_rate=44100, hop_length=512,device=None):
85
- x = wav_numpy
86
- if p_len is None:
87
- p_len = x.shape[0]//hop_length
88
- else:
89
- assert abs(p_len-x.shape[0]//hop_length) < 4, "pad length error"
90
-
91
- f0_min = 50
92
- f0_max = 1100
93
- F0Creper = CrepePitchExtractor(hop_length=hop_length,f0_min=f0_min,f0_max=f0_max,device=device)
94
- f0,uv = F0Creper(x[None,:].float(),sampling_rate,pad_to=p_len)
95
- return f0,uv
96
 
97
  def plot_data_to_numpy(x, y):
98
  global MATPLOTLIB_FLAG
 
6
  import logging
7
  import json
8
  import subprocess
 
9
  import random
 
10
 
11
  import librosa
12
  import numpy as np
 
15
  from torch.nn import functional as F
16
  from modules.commons import sequence_mask
17
  from hubert import hubert_model
 
 
18
  MATPLOTLIB_FLAG = False
19
 
20
  logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
 
46
  # factor = torch.ones(f0.shape[0], 1, 1).to(f0.device)
47
  # f0_norm = (f0 - means.unsqueeze(-1)) * factor.unsqueeze(-1)
48
  # return f0_norm
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  def normalize_f0(f0, x_mask, uv, random_scale=True):
50
  # calculate means based on x_mask
51
  uv_sum = torch.sum(uv, dim=1, keepdim=True)
 
62
  exit(0)
63
  return f0_norm * x_mask
64
 
 
 
 
 
 
 
 
 
 
 
 
 
65
 
66
  def plot_data_to_numpy(x, y):
67
  global MATPLOTLIB_FLAG