When creating a post, please add:
- Week # must be added in the tags option of the post.
- Link to the classroom item you are referring to:
- Description (include relevant info but please do not post solution code or your entire notebook)
Iamworking in Assignment on Trigger Words. Week3 Course 5.
While testing the function def create_training_example(background, activates, negatives, Ty): ,
After submit, this following msg appears.
Cell #25. Can’t compile the student’s code. Error: AttributeError(“‘list’ object has no attribute ‘channels’”)
Posting the complete output here
AttributeError Traceback (most recent call last)
in
19 print(“\033[92m All tests passed!”)
20
—> 21 create_training_example_test(create_training_example)
in create_training_example_test(target)
4 def create_training_example_test(target):
5 np.random.seed(18)
----> 6 x, y = target(backgrounds[0], activates, negatives, 1375)
7
8 assert type(x) == np.ndarray, “Wrong type for x”
in create_training_example(background, activates, negatives, Ty)
37 for one_random_activate in random_activates:
38 # Insert the audio clip on the background
—> 39 background, segment_time = insert_audio_clip(background,random_activates,previous_segments)
40 # Retrieve segment_start and segment_end from segment_time
41 segment_start, segment_end = segment_time
in insert_audio_clip(background, audio_clip, previous_segments)
40 ### END CODE HERE ###
41 # Step 4: Superpose audio segment and background
—> 42 new_background = background.overlay(audio_clip, position = segment_time[0])
43 else:
44 #print(“Timeouted”)
/opt/conda/lib/python3.7/site-packages/pydub/audio_segment.py in overlay(self, seg, position, loop, times, gain_during_overlay)
1151 output = StringIO()
1152
→ 1153 seg1, seg2 = AudioSegment._sync(self, seg)
1154 sample_width = seg1.sample_width
1155 spawn = seg1._spawn
/opt/conda/lib/python3.7/site-packages/pydub/audio_segment.py in _sync(cls, *segs)
434 @classmethod
435 def _sync(cls, *segs):
→ 436 channels = max(seg.channels for seg in segs)
437 frame_rate = max(seg.frame_rate for seg in segs)
438 sample_width = max(seg.sample_width for seg in segs)
/opt/conda/lib/python3.7/site-packages/pydub/audio_segment.py in (.0)
434 @classmethod
435 def _sync(cls, *segs):
→ 436 channels = max(seg.channels for seg in segs)
437 frame_rate = max(seg.frame_rate for seg in segs)
438 sample_width = max(seg.sample_width for seg in segs)
AttributeError: ‘list’ object has no attribute ‘channels’