25
25
import sys
26
26
import zipfile
27
27
28
+ import fsspec
28
29
import pandas
29
30
import soundfile as sf
30
- import tensorflow as tf
31
31
from absl import logging
32
32
33
- gfile = tf .compat .v1 .gfile
34
33
35
34
SUBSETS = {
36
35
"vox1_dev_wav" : [
@@ -73,8 +72,7 @@ def download_and_extract(directory, subset, urls):
73
72
subset: subset name of the corpus.
74
73
urls: the list of urls to download the data file.
75
74
"""
76
- if not gfile .Exists (directory ):
77
- gfile .MakeDirs (directory )
75
+ fsspec .get_mapper (directory ).fs .makedirs (directory , exist_ok = True )
78
76
79
77
try :
80
78
for url in urls :
@@ -107,7 +105,7 @@ def download_and_extract(directory, subset, urls):
107
105
extract_path_ori = os .path .join (directory , zfile .infolist ()[0 ].filename )
108
106
subprocess .call ("mv %s %s" % (extract_path_ori , extract_path ), shell = True )
109
107
finally :
110
- # gfile.Remove (zip_filepath)
108
+ # fsspec.get_mapper(directory).fs.rm_file (zip_filepath)
111
109
pass
112
110
113
111
@@ -160,7 +158,8 @@ def convert_audio_and_make_label(input_dir, subset, output_dir, output_file):
160
158
161
159
files = []
162
160
# Convert all AAC file into WAV format. At the same time, generate the csv
163
- for root , _ , filenames in gfile .Walk (source_dir ):
161
+ fs = fsspec .get_mapper (source_dir ).fs
162
+ for root , _ , filenames in fs .walk (source_dir ):
164
163
for filename in filenames :
165
164
name , ext = os .path .splitext (filename )
166
165
if ext .lower () == ".wav" :
@@ -172,7 +171,7 @@ def convert_audio_and_make_label(input_dir, subset, output_dir, output_file):
172
171
# Convert AAC to WAV.
173
172
aac_file = os .path .join (root , filename )
174
173
wav_file = aac_file + ".wav"
175
- if not gfile . Exists (wav_file ):
174
+ if not fs . exists (wav_file ):
176
175
if not decode_aac_with_ffmpeg (aac_file , wav_file ):
177
176
raise RuntimeError ("Audio decoding failed." )
178
177
else :
0 commit comments