Fixed minor issues

This commit is contained in:
Thorsten Mueller 2022-02-15 17:52:03 +01:00
parent 77ad01d4ff
commit b5ec9ef991

View File

@ -61,6 +61,9 @@ def convert_audio():
print('→ Converting %s Audio Files to 22050 Hz, 16 Bit, Mono\n' % "{:,}".format(recordings)) print('→ Converting %s Audio Files to 22050 Hz, 16 Bit, Mono\n' % "{:,}".format(recordings))
# Please use `pip install ffmpeg-python`
import ffmpeg
for idx, wav in enumerate(glob.glob(os.path.join(output_dir_audio_temp, "*.wav"))): for idx, wav in enumerate(glob.glob(os.path.join(output_dir_audio_temp, "*.wav"))):
percent = (idx + 1) / recordings percent = (idx + 1) / recordings
@ -75,11 +78,6 @@ def convert_audio():
.run(capture_stdout=True) .run(capture_stdout=True)
) )
# Delete Temp File
os.remove(wav)
# Remove Temp Folder
rmtree(output_dir_audio_temp)
def copy_audio(): def copy_audio():
global output_dir_audio global output_dir_audio
@ -90,7 +88,7 @@ def copy_audio():
print('→ Copy %s Audio Files to LJSpeech Dataset\n' % "{:,}".format(recordings)) print('→ Copy %s Audio Files to LJSpeech Dataset\n' % "{:,}".format(recordings))
for idx, wav in enumerate(glob.glob(os.path.join(output_dir_audio_temp, "*.wav"))): for idx, wav in enumerate(glob.glob(os.path.join(output_dir_audio_temp, "*.wav"))):
shutil.copyfile(wav,os.path.join(output_dir_audio, os.path.basename(wav))) copyfile(wav,os.path.join(output_dir_audio, os.path.basename(wav)))
def create_meta_data(mrs_dir): def create_meta_data(mrs_dir):
print('→ Creating META Data') print('→ Creating META Data')
@ -125,6 +123,12 @@ def create_meta_data(mrs_dir):
metadata.close() metadata.close()
conn.close() conn.close()
def cleanup():
global output_dir_audio_temp
# Remove Temp Folder
rmtree(output_dir_audio_temp)
def main(): def main():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument('--mrs_dir', required=True) parser.add_argument('--mrs_dir', required=True)
@ -140,11 +144,12 @@ def main():
create_meta_data(args.mrs_dir) create_meta_data(args.mrs_dir)
if(args.ffmpeg): if(args.ffmpeg):
import ffmpeg
convert_audio() convert_audio()
else: else:
copy_audio() copy_audio()
cleanup()
print('\n\033[38;5;86;1m✔\033[0m COMPLETE【ツ】\n') print('\n\033[38;5;86;1m✔\033[0m COMPLETE【ツ】\n')