C5 W3 A2: Trigger Word Detection

These line of check codes start to run infinitely until I have to interrupt them. These are placed after the function definition of insert_audio_clip in my notebook. This is causing an error in grader. I have tried hours and hours but no result. Can you please guide why is this issue coming up


def insert_audio_clip_test(target):
audio_clip, segment_time = target(backgrounds[0], activates[0], [(0, 4400)])
duration = segment_time[1] - segment_time[0]
assert segment_time[0] > 4400, “Error: The audio clip is overlaping with the first segment”
assert duration + 1 == len(activates[0]) , “The segment length must match the audio clip length”
assert audio_clip != backgrounds[0] , “The audio clip must be different than the pure background”
assert segment_time == (7286, 8201), f"Wrong segment. Expected: Expected: (7286, 8201) got:{segment_time}"

# Not possible to insert clip into background
audio_clip, segment_time = target(backgrounds[0], activates[0], [(0, 9999)])
assert segment_time == (10000, 10000), "Segment must match the out by max-retry mark"
assert audio_clip == backgrounds[0], "output audio clip must be exactly the same input background"

print("\033[92m All tests passed!")


If your insert_audio_clip() contains an infinite loop, it’s possible that you either…

  • left out the “and retry >= 0” part of the “while” loop,
  • left out the code that decrements the retry counter.

Yes Thank you. I checked and I was missing retry condition in the loop. It is all working now