@@ -17,12 +17,12 @@ def read_csv(fn, header=True, add_label=False):
17
17
"""Reads a CSV file
18
18
19
19
Args:
20
- fn: Filename
21
- header: Boolean
22
- add_label: Add column with constant value of `add_label`
20
+ fn (str) : Filename
21
+ header (bool) : Boolean (Default value = True)
22
+ add_label (bool) : Add column with constant value of `add_label` (Default value = False)
23
23
24
24
Returns:
25
- df: Pandas DataFrame
25
+ df (pd.DataFrame) : Pandas DataFrame
26
26
"""
27
27
df = pd .read_csv (fn , sep = ';' , keep_default_na = False , header = 0 if header else None )
28
28
if add_label :
@@ -35,29 +35,27 @@ def write_csv(df, fn, header=True):
35
35
"""Writes a CSV file
36
36
37
37
Args:
38
- df: Pandas DataFrame
39
- fn: Filename
40
- header: Boolean
38
+ df (pd.DataFrame) : Pandas DataFrame
39
+ fn (str) : Filename
40
+ header (bool) : Boolean (Default value = True)
41
41
"""
42
42
df .to_csv (fn , sep = ';' , index = False , quoting = 2 , header = header )
43
43
44
44
45
45
def cut_audio (fn_in , fn_out , start_sec , end_sec , normalize = True , write = True , Fs = 22050 ):
46
46
"""Cuts an audio file
47
47
48
- Notebook: B/B_Annotations_cut.ipynb
49
-
50
48
Args:
51
- fn_in: Filename and path for input audio file
52
- fn_out: Filename and path for input audio file
53
- start_sec: Start time position (in seconds) of cut
54
- end_sec: End time position (in seconds) of cut
55
- normalize: If True, then normalize audio (with max norm)
56
- write: If True, then write audio
57
- Fs: Sampling rate of audio
49
+ fn_in (str) : Filename and path for input audio file
50
+ fn_out (str) : Filename and path for input audio file
51
+ start_sec (float) : Start time position (in seconds) of cut
52
+ end_sec (float) : End time position (in seconds) of cut
53
+ normalize (bool) : If True, then normalize audio (with max norm) (Default value = True )
54
+ write (bool) : If True, then write audio (Default value = True)
55
+ Fs (scalar) : Sampling rate of audio (Default value = 22050)
58
56
59
57
Returns:
60
- x_cut: Cut audio
58
+ x_cut (np.ndarray) : Cut audio
61
59
"""
62
60
x_cut , Fs = librosa .load (fn_in , sr = Fs , offset = start_sec , duration = end_sec - start_sec )
63
61
if normalize is True :
@@ -70,17 +68,15 @@ def cut_audio(fn_in, fn_out, start_sec, end_sec, normalize=True, write=True, Fs=
70
68
def cut_csv_file (fn_in , fn_out , start_sec , end_sec , write = True ):
71
69
"""Cuts csv annotation file
72
70
73
- Notebook: B/B_Annotations_cut.ipynb
74
-
75
71
Args:
76
- fn_in: Filename and path for input audio file
77
- fn_out: Filename and path for input audio file
78
- start_sec: Start time position (in seconds) of cut
79
- end_sec: End time position (in seconds) of cut
80
- write: If True, then write audio
72
+ fn_in (str) : Filename and path for input audio file
73
+ fn_out (str) : Filename and path for input audio file
74
+ start_sec (float) : Start time position (in seconds) of cut
75
+ end_sec (float) : End time position (in seconds) of cut
76
+ write (bool) : If True, then write audio (Default value = True)
81
77
82
78
Returns:
83
- ann_cut: Cut annotation file
79
+ ann_cut (list) : Cut annotation file
84
80
"""
85
81
df = pd .read_csv (fn_in , sep = ',' , keep_default_na = False , header = None )
86
82
ann_cut = []
0 commit comments