W3-Assignment 2

How can I make sure audio clip length and segment length are same?

Getting Error in insert_audio_clip method:
Audio Clip Duration: 916
Segment Duration: 20.77097505668934

AssertionError Traceback (most recent call last)
16 print(“\033[92m All tests passed!”)
—> 18 insert_audio_clip_test(insert_audio_clip)

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

AssertionError: The segment length must match the audio clip length

Audio length and duration + 1 must match since we are placing the audio clip within the background and returning the time segment that matches the duration of the audio clip that was placed within the background.

activates[0] is of length 916 but the duration + 1 is not. Please use this hint to fix your implementation.

Sir I tried to utilize your hint, but still getting same error

  1. As far as the assignment is concerned, please fill code only where required. For instance, you’ve changed retry = 5 to retry = 50. This could let the grader / tests to evaluate your submission incorrectly.
  2. Calculation of segment_ms is incorrect. The calculation in the notebook is correct and so you don’t have to adjust it manually.
  3. There’s no need for this check: if duration != len(audio_clip) + 1: since it’ll always be False
    Do read the section Important Note on Submission to the AutoGrader and get a fresh copy of the assignment to start over.
1 Like