vinthony commited on
Commit
639be9b
1 Parent(s): fa7bc69

Update src/generate_batch.py

Browse files
Files changed (1) hide show
  1. src/generate_batch.py +8 -0
src/generate_batch.py CHANGED
@@ -62,7 +62,15 @@ def get_data(first_coeff_path, audio_path, device):
62
  source_semantics_dict = scio.loadmat(source_semantics_path)
63
  ref_coeff = source_semantics_dict['coeff_3dmm'][:1,:70] #1 70
64
 
 
 
 
 
 
 
 
65
  wav = audio.load_wav(audio_path, 16000)
 
66
  wav_length, num_frames = parse_audio_length(len(wav), 16000, 25)
67
  wav = crop_pad_audio(wav, wav_length)
68
  orig_mel = audio.melspectrogram(wav).T
 
62
  source_semantics_dict = scio.loadmat(source_semantics_path)
63
  ref_coeff = source_semantics_dict['coeff_3dmm'][:1,:70] #1 70
64
 
65
+ if '.mp3' in audio_path:
66
+ new_audio = audio_path.replace('.mp3', '.wav')
67
+ command = 'ffmpeg -i '+ audio_path + ' -acodec pcm_s16le -ac 1 -ar 16000 ' + new_audio
68
+ subprocess.call(command, shell=platform.system() != 'Windows')
69
+ else:
70
+ new_audio = audio_path
71
+
72
  wav = audio.load_wav(audio_path, 16000)
73
+
74
  wav_length, num_frames = parse_audio_length(len(wav), 16000, 25)
75
  wav = crop_pad_audio(wav, wav_length)
76
  orig_mel = audio.melspectrogram(wav).T