MCPcopy Create free account
hub / github.com/MoonInTheRiver/DiffSinger / convert_continuos_f0

Function convert_continuos_f0

utils/cwt.py:12–43  ·  view source on GitHub ↗

CONVERT F0 TO CONTINUOUS F0 Args: f0 (ndarray): original f0 sequence with the shape (T) Return: (ndarray): continuous f0 with the shape (T)

(f0)

Source from the content-addressed store, hash-verified

10
11
12def convert_continuos_f0(f0):
13 '''CONVERT F0 TO CONTINUOUS F0
14 Args:
15 f0 (ndarray): original f0 sequence with the shape (T)
16 Return:
17 (ndarray): continuous f0 with the shape (T)
18 '''
19 # get uv information as binary
20 f0 = np.copy(f0)
21 uv = np.float32(f0 != 0)
22
23 # get start and end of f0
24 if (f0 == 0).all():
25 print("| all of the f0 values are 0.")
26 return uv, f0
27 start_f0 = f0[f0 != 0][0]
28 end_f0 = f0[f0 != 0][-1]
29
30 # padding start and end of f0 sequence
31 start_idx = np.where(f0 == start_f0)[0][0]
32 end_idx = np.where(f0 == end_f0)[0][-1]
33 f0[:start_idx] = start_f0
34 f0[end_idx:] = end_f0
35
36 # get non-zero frame index
37 nz_frames = np.where(f0 != 0)[0]
38
39 # perform linear interpolation
40 f = interp1d(nz_frames, f0[nz_frames])
41 cont_f0 = f(np.arange(0, f0.shape[0]))
42
43 return uv, cont_f0
44
45
46def get_cont_lf0(f0, frame_period=5.0):

Callers 1

get_cont_lf0Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected