Error while generating training examples

Hello,
I am trying to insert the code data that I collected. The data also contained ‘activates’, backgrounds, and negatives but in a different language. and the length of the audio clips with ‘activates’ are changing largely, they do not have the same durations.
when I come to the part of create_training_example I am getting the following error

ValueError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_44624\1184543871.py in
8 if i%100 == 0:
9 print(i)
—> 10 x, y = create_training_example(backgrounds[i % 2], activates, Ty)
11 X.append(x.swapaxes(0,1))
12 Y.append(y.swapaxes(0,1))

~\AppData\Local\Temp\ipykernel_44624\2055369461.py in create_training_example(background, activates, Ty)
37 for random_activate in random_activates: # @KEEP
38 # Insert the audio clip on the background
—> 39 background, segment_time = insert_audio_clip(background, random_activate, previous_segments)
40 # Retrieve segment_start and segment_end from segment_time
41 segment_start, segment_end = segment_time

~\AppData\Local\Temp\ipykernel_44624\843879900.py in insert_audio_clip(background, audio_clip, previous_segments)
22 # Step 1: Use one of the helper functions to pick a random time segment onto which to insert
23 # the new audio clip. (≈ 1 line)
—> 24 segment_time = get_random_time_segment(segment_ms)
25
26 # Step 2: Check if the new segment_time overlaps with one of the previous_segments. If so, keep

~\AppData\Local\Temp\ipykernel_44624\973852698.py in get_random_time_segment(segment_ms)
10 “”"
11
—> 12 segment_start = np.random.randint(low=0, high=9000-segment_ms) # Make sure segment doesn’t run past the 10sec background
13 segment_end = segment_start + segment_ms - 1
14

mtrand.pyx in numpy.random.mtrand.RandomState.randint()

_bounded_integers.pyx in numpy.random._bounded_integers._rand_int32()

ValueError: high <= 0

why it is happening?, I tried to change the high to 9000 in order to solve the problem but it does not work. can someone help with this?

I assume you’re working from C4 W4 A2 (trigger words).

For the method given in this assignment, all of the audio clips must be the same length.

There are other details in sections 1.2 and 1.3.

Also, I think there are some mistakes in your insert_audio_clip() function. Does it pass the tests in the original notebook?

1 Like

thank you very much for your reply,
I think that the problem was in the ‘activate’ clips that I collected, one of them had a length of 11 seconds which is longer than the background clip. After excluding it the code worked.