# C5 W3 A2: Trigger Word Detection

**URL:** <https://community.deeplearning.ai/t/c5-w3-a2-trigger-word-detection/47937>\
**Category:** Sequence Models\
**Tags:** coursera-platform\
**Created:** [October 10, 2021, 3:04am UTC](https://community.deeplearning.ai/t/c5-w3-a2-trigger-word-detection/47937 "2021-10-10T03:04:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Osama-Mustafa](https://avatars.discourse-cdn.com/v4/letter/o/e95f7d/32.png) [@Osama-Mustafa](https://community.deeplearning.ai/u/Osama-Mustafa)\
**Post date:** [October 10, 2021, 3:04am UTC](https://community.deeplearning.ai/t/c5-w3-a2-trigger-word-detection/47937/1 "2021-10-10T03:04:55Z")

</div>

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

# UNIT TEST

def insert\_audio\_clip\_test(target):  
np.random.seed(5)  
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!")

```

insert\_audio\_clip\_test(insert\_audio\_clip)

---

<div class="post-metadata">

**Author:** ![TMosh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/tmosh/32/9321_2.png) [@TMosh](https://community.deeplearning.ai/u/TMosh)\
**Post date:** [October 12, 2021, 6:19am UTC](https://community.deeplearning.ai/t/c5-w3-a2-trigger-word-detection/47937/2 "2021-10-12T06:19:43Z")

</div>

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,  
or…
- left out the code that decrements the retry counter.

---

<div class="post-metadata">

**Author:** ![Osama-Mustafa](https://avatars.discourse-cdn.com/v4/letter/o/e95f7d/32.png) [@Osama-Mustafa](https://community.deeplearning.ai/u/Osama-Mustafa)\
**Post date:** [October 12, 2021, 10:48am UTC](https://community.deeplearning.ai/t/c5-w3-a2-trigger-word-detection/47937/3 "2021-10-12T10:48:23Z")

</div>

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