Spaces:
Running
Running
kevinwang676
commited on
Commit
·
ef880b4
1
Parent(s):
c90210a
Update utils/pitch_ld_extraction.py
Browse files
utils/pitch_ld_extraction.py
CHANGED
@@ -60,9 +60,12 @@ def REAPER_F0(wav_path, sr=24000, frame_period=0.01): # frame_period s
|
|
60 |
cmd = f'reaper-tmp/REAPER/build/reaper -i {wav_path} -f {wav_path}.f0 -e {frame_period} -x 1000 -m 65 -a'
|
61 |
os.system(cmd)
|
62 |
f0 = []
|
63 |
-
|
64 |
-
|
65 |
-
|
|
|
|
|
|
|
66 |
|
67 |
cmd = f'rm -f {wav_path}.f0'
|
68 |
os.system(cmd)
|
@@ -159,7 +162,8 @@ def compute_pitch(wav_path: str, pitch_path: str=None, frame_period=0.01):
|
|
159 |
compute_median.append(f0)
|
160 |
# Compute pitch using REAPER algorithm
|
161 |
f0 = REAPER_F0(wav_path, sr=fs, frame_period=frame_period)
|
162 |
-
|
|
|
163 |
|
164 |
# Compute median F0
|
165 |
compute_median = pad_arrays(compute_median, f0_std_len)
|
@@ -249,4 +253,4 @@ if __name__ == '__main__':
|
|
249 |
parser.add_argument('--n_cpu', type=int, default=1)
|
250 |
|
251 |
args = parser.parse_args()
|
252 |
-
main(args)
|
|
|
60 |
cmd = f'reaper-tmp/REAPER/build/reaper -i {wav_path} -f {wav_path}.f0 -e {frame_period} -x 1000 -m 65 -a'
|
61 |
os.system(cmd)
|
62 |
f0 = []
|
63 |
+
try:
|
64 |
+
with open(f'{wav_path}.f0', 'r') as rf:
|
65 |
+
for line in rf.readlines()[7:]:
|
66 |
+
f0.append(float(line.split()[2]))
|
67 |
+
except FileNotFoundError as e:
|
68 |
+
return None
|
69 |
|
70 |
cmd = f'rm -f {wav_path}.f0'
|
71 |
os.system(cmd)
|
|
|
162 |
compute_median.append(f0)
|
163 |
# Compute pitch using REAPER algorithm
|
164 |
f0 = REAPER_F0(wav_path, sr=fs, frame_period=frame_period)
|
165 |
+
if f0 is not None:
|
166 |
+
compute_median.append(f0)
|
167 |
|
168 |
# Compute median F0
|
169 |
compute_median = pad_arrays(compute_median, f0_std_len)
|
|
|
253 |
parser.add_argument('--n_cpu', type=int, default=1)
|
254 |
|
255 |
args = parser.parse_args()
|
256 |
+
main(args)
|