Trigger word detection - Spectrogram is wrong

Hi team,

For the assignment to define create_training_example, I passed my code online, while when i double checked it offline, it pops up an error as follows:

What might be the issue?

Were you able to fix this issue?

Hi,
I have this issue too please help me

Please start a new thread for your question. This thread ended 4 months ago.

Hi Mandyzmr and others in the thread,

Sorry for this late response. The trace log/ error log itself is trying to hint you that you are referring the wrong parameters somewhere in the insert_audio_clip section of the create_training_example. Do not copy paste the variables or parameters as such otherwise, it won’t give you the expected outcome.

Rashmi, I am having the same issue : “Spectrogram is wrong. Check the parameters passed to the insert_audio_clip function”. And I have reviewed my inputs carefully. I am thinking that the expected wrong answer has to do with identifying the audio clips to be inserted, but I have been careful and would be really surprised if I have this wrong. Can you provide any more insight?

Hello Edward,

Welcome to the community.

Sorry for this late reply.

Did you follow these instructions mentioned within the notebook?

Exercise 2 - insert_audio_clip

  • Implement insert_audio_clip() to overlay an audio clip onto the background 10sec clip.
  • You implement 4 steps:
  • Get the length of the audio clip that is to be inserted.
    • Get a random time segment whose duration equals the duration of the audio clip that is to be inserted.
  • Make sure that the time segment does not overlap with any of the previous time segments.
    • If it is overlapping, then go back to step 1 and pick a new time segment.
  • Append the new time segment to the list of existing time segments
    • This keeps track of all the segments you’ve inserted.
  • Overlay the audio clip over the background using pydub. We have implemented this for you.

Insert audio clip

  • Let’s use the previous helper functions to insert a new audio clip onto the 10 second background at a random time.
  • We will ensure that any newly inserted segment doesn’t overlap with previously inserted segments.

Just go through once again and let me know, and then we can work on the issue again.

Hi Rashmi,

I actually have 2 issues with the Trigger Word Detection Programming assignment. I will review them in the order of occurrence in the assignment. I think both issues are a result of recent updates to this programming exercise.

The first is with the function insert_audio_clip. When I programmed this function in the Notebook within Coursera, it passed, no issues. When I downloaded the program and all of the support files, and ran it locally, it failed the line: # assert segment_time == (7286, 8201), f"Wrong segment. Expected: Expected: (7286, 8201) got:{segment_time}" in the Unit Test. I am finding in the unit test, that the target audio files, selected by the unit test do no match between my down loaded files and the those being executed by Coursera.

The second issue is with the create_training_example function where it fails the code line: np.isclose(np.linalg.norm(x), 39745552.52075), “Spectrogram is wrong. Check the parameters passed to the insert_audio_clip function” in the Unit Test.

My code fails on both my downloaded files as well as that being executed on the Coursera platform**.** Again, I have looked at this extensively, and I believe the issues is with the files retreated by the Test function.

But to be sure, I have attached my code. I have spent so much time looking at this and I just do not see an error. I would really appreciate it if you can look over my attachment and let me know if I have made an mistake because I do not have a clue.

What is really interesting here is my Programming submission achieved a 100% grade.

Your thoughts,

Much appreciated,

Ed Spivey

(Attachment create_training_example function.docx is missing)

Rashmi, I am resending this email with an approved attachment.

Hi Rashmi,

I actually have 2 issues with the Trigger Word Detection Programming assignment. I will review them in the order of occurrence in the assignment. I think both issues are a result of recent updates to this programming exercise.

The first is with the function insert_audio_clip. When I programmed this function in the Notebook within Coursera, it passed, no issues. When I downloaded the program and all of the support files, and ran it locally, it failed the line: # assert segment_time == (7286, 8201), f"Wrong segment. Expected: Expected: (7286, 8201) got:{segment_time}" in the Unit Test. I am finding in the unit test, that the target audio files, selected by the unit test do no match between my down loaded files and the those being executed by Coursera.

The second issue is with the create_training_example function where it fails the code line: np.isclose(np.linalg.norm(x), 39745552.52075), “Spectrogram is wrong. Check the parameters passed to the insert_audio_clip function” in the Unit Test.

My code fails on both my downloaded files as well as that being executed on the Coursera platform**.** Again, I have looked at this extensively, and I believe the issues is with the files retreated by the Test function.

But to be sure, I have attached my code. I have spent so much time looking at this and I just do not see an error. I would really appreciate it if you can look over my attachment and let me know if I have made an mistake because I do not have a clue.

What is really interesting here is my Programming submission achieved a 100% grade.

Your thoughts,

Much appreciated,

Ed Spivey
Moderator edit, code removed.

Hello Edward,

In Step 3, you just have to retrieve ‘segment start and segment end’ of the audio clip from the segment time and not from the difference using random time segments . I think you have mentioned the parameters wrong here to call the function.

Please revisit the step 3 again.

Also, do not forget to run all the cells from the beginning using shift+enter key by restarting the kernel and clearing all the outputs before you rewrite the code.

Hope, that works for you!

Hello Edward,

In Step 3, you just have to retrieve ‘segment start and segment end’ of the audio clip from the segment time and not from the difference using random time segments . I think you have mentioned the parameters wrong here to call the function.

Please revisit the step 3 again.

Also, do not forget to run all the cells from the beginning using shift+enter key by restarting the kernel and clearing all the outputs before you rewrite the code.

Hope, that works for you!

Besides, check the format of the audio clip. It should be .wav.

I wanted to drop a quick note to say how much I appreciated your response, Thank you, Ed

You are so welcome.

Keep learning, Edward!