C5W3 Assignment 2 Exercise 4: Spectrogram is wrong. Check the parameters passed to the insert_audio_clip function

I read all other comments on this topic and I was not able to solve the problem. Any help would be appreciated.

Notes:
My “insert_audio_clip” function not only pass al tests but it also does includes:
-segment_time = get_random_time_segment()
-appends each new ‘segment_time’ to previous_segments
-uses '“is_overlapping()” in the “while” loop
Also, I have tried re-starting the Kernel and running all cells in order again
My submission results in 0/100 points even though I passed all tests except this one

Hi @Rodolfo_Novarini ,

If is difficult to tell what your problem might be without any error report/message.

Adding the error message:


AssertionError Traceback (most recent call last)
in
17 print(“\033[92m All tests passed!”)
18
—> 19 create_training_example_test(create_training_example)

in create_training_example_test(target)
13 assert np.sum(y) >= 50, “It must contain at least one activate”
14 assert np.sum(y) % 50 == 0, “Sum of activate marks must be a multiple of 50”
—> 15 assert np.isclose(np.linalg.norm(x), 39745552.52075), “Spectrogram is wrong. Check the parameters passed to the insert_audio_clip function”
16
17 print(“\033[92m All tests passed!”)

AssertionError: Spectrogram is wrong. Check the parameters passed to the insert_audio_clip function

Hi @Rodolfo_Novarini ,

In the code for create_training_example() function, please check the correct parameters are passed to the function insert_audio_clip(), it should be the same as how insert_audio_clip() is defined.

The parameters I am passing are:
insert_audio_clip(background, audio_clip, previous_segments)
where audio_clip depends on the specific clip I’m passing (activate or negative)

Hi @Kic just found the error. It was in “segment_start, segment_end =” instead of passing the tuple that was already generated by the function insert_audio_clip(), I was running the function get_random_time_segment() generating a random “segment_start, segment_end” that were different than the one where the clip was inserted.

Thanks for your help. It might be worth to include a check on that line as part of the tests in order to be able to give a more specific feedback to students.

If I understand this post and response correctly it sounds like the segment_time in the code line ‘segment_start, segment_end = segment_time’ is not the same value as that was inserted into the line above ‘background, segment_time = insert_audio_clip(background, random_activate, previous_segments)’ but I do not understand how they could be different (i.e. ? one is random, the other is not -also there is no ‘get_random_time_segment()’ function in exercise #4

My issue here is that this error seem to prevent the WHOLE notebook, from being compilable (for some reason), so the assigned grade is 0, despite the fact that everything prior to this has been passed, and interestingly everything after exercise #4 in this notebook appears to run correctly, with no error messages generated, The message from the automatic grader was 'Cell #25. Can’t compile the student’s code. Error: FileNotFoundError(2, ‘No such file or directory’). ('Another user also noted that the assigned grade was 0 for this notebook)

Thanks for any further help you might provide

…also there is no ‘get_random_time_segment()’ function in exercise #4

The "get_random_time_segment() function " is defined in section 1.3 of the notebook.

thanks - this helped