atsushieee commited on
Commit
e417f48
·
1 Parent(s): 3821062

Update pitch/inference.py

Browse files
Files changed (1) hide show
  1. pitch/inference.py +21 -4
pitch/inference.py CHANGED
@@ -55,7 +55,20 @@ def compute_f0_voice(filename, device):
55
  fmax = 1000
56
  model = "full"
57
  batch_size = 512
58
- pitch = crepe.predict(
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  audio,
60
  sr,
61
  hop_length,
@@ -64,9 +77,12 @@ def compute_f0_voice(filename, device):
64
  model,
65
  batch_size=batch_size,
66
  device=device,
67
- return_periodicity=False,
68
  )
69
- pitch = crepe.filter.mean(pitch, 3)
 
 
 
70
  pitch = pitch.squeeze(0)
71
  return pitch
72
 
@@ -128,7 +144,8 @@ if __name__ == "__main__":
128
  print(args.pit)
129
 
130
  device = "cuda" if torch.cuda.is_available() else "cpu"
131
- pitch = compute_f0_sing(args.wav, device)
 
132
  save_csv_pitch(pitch, args.pit)
133
  # tmp = load_csv_pitch(args.pit)
134
  # save_csv_pitch(tmp, "tmp.csv")
 
55
  fmax = 1000
56
  model = "full"
57
  batch_size = 512
58
+ # pitch = crepe.predict(
59
+ # audio,
60
+ # sr,
61
+ # hop_length,
62
+ # fmin,
63
+ # fmax,
64
+ # model,
65
+ # batch_size=batch_size,
66
+ # device=device,
67
+ # return_periodicity=False,
68
+ # )
69
+ # pitch = crepe.filter.mean(pitch, 3)
70
+ # pitch = pitch.squeeze(0)
71
+ pitch, periodicity = crepe.predict(
72
  audio,
73
  sr,
74
  hop_length,
 
77
  model,
78
  batch_size=batch_size,
79
  device=device,
80
+ return_periodicity=True,
81
  )
82
+ # CREPE was not trained on silent audio. some error on silent need filter.pitPath
83
+ periodicity = crepe.filter.median(periodicity, 7)
84
+ pitch = crepe.filter.mean(pitch, 5)
85
+ pitch[periodicity < 0.5] = 0
86
  pitch = pitch.squeeze(0)
87
  return pitch
88
 
 
144
  print(args.pit)
145
 
146
  device = "cuda" if torch.cuda.is_available() else "cpu"
147
+ # pitch = compute_f0_sing(args.wav, device)
148
+ pitch = compute_f0_voice(args.wav, device)
149
  save_csv_pitch(pitch, args.pit)
150
  # tmp = load_csv_pitch(args.pit)
151
  # save_csv_pitch(tmp, "tmp.csv")