@Juan_Olano it does work. I just tested it by running a cell on Coursera with this code:
os.listdir('./raw_data/' + "activates"), os.listdir('./raw_data/' + "backgrounds"), os.listdir('./raw_data/' + "negatives")
which returns:
(['3_act2.wav',
'2_act3.wav',
'1_act2.wav',
'2.wav',
'3_act3.wav',
'4_act2.wav',
'1.wav',
'1_act3.wav',
'2_act2.wav',
'3.wav'],
['2.wav', '1.wav'],
['4.wav',
'3_2.wav',
'1_0.wav',
'2.wav',
'2_1.wav',
'5.wav',
'5_1.wav',
'1.wav',
'3.wav',
'4_0.wav'])
I then changed on my computer the result from os.listdir
to this list and all asserts pass. That means that the order returned by os.listdir
differs between my computer and Coursera.
So, the solution is to change the function load_raw_audio
(on td_utils.py) to the following (notice that each os.listdir
is enclosed by a sorted as sorted(os.listdir(***))
):
# Load raw audio files for speech synthesis
def load_raw_audio(path):
activates = []
backgrounds = []
negatives = []
for filename in sorted(os.listdir(path + "activates")):
if filename.endswith("wav"):
activate = AudioSegment.from_wav(path + "activates/" + filename)
activates.append(activate)
for filename in sorted(os.listdir(path + "backgrounds")):
if filename.endswith("wav"):
background = AudioSegment.from_wav(path + "backgrounds/" + filename)
backgrounds.append(background)
for filename in sorted(os.listdir(path + "negatives")):
if filename.endswith("wav"):
negative = AudioSegment.from_wav(path + "negatives/" + filename)
negatives.append(negative)
return activates, negatives, backgrounds
After doing this change you need to fix the asserts according to what you want to test. For instance in the the function def insert_audio_clip_test(target):
(on notebook), you would need to change background[0]
to background[1]
and activates[0]
to activates[7]
. Also you should check other tests using an assert
and some of the files created by the os.listdir
.
It’s a very easy fix, hope you can implement it on production.