aws-samples / aws-samples/amazon-transcribe-post-call-analytics
list index out of range
- Dominant language
- Python
- Stars
- 109
- Forks
- 89
- PR merge metrics
- No merged PRs in 30d
Description
[ERROR] IndexError: list index out of range
Traceback (most recent call last):
File "/var/task/pca-aws-sf-process-turn-by-turn.py", line 1199, in lambda_handler
transcribeParser.parse_transcribe_file(sf_data)
File "/var/task/pca-aws-sf-process-turn-by-turn.py", line 1161, in parse_transcribe_file
self.speechSegmentList = self.create_turn_by_turn_segments(sf_event)
File "/var/task/pca-aws-sf-process-turn-by-turn.py", line 787, in create_turn_by_turn_segments
last_word = nextSpeechSegment.segmentConfidence[-1]
You need to validate whether the list "nextSpeechSegment.segmentConfidence" is not empty:
if word["Type"] == "pronunciation":
...
else:
# Punctuation, needs to be added to the previous word
last_word = nextSpeechSegment.segmentConfidence[-1] <=== Exception in this line
last_word["Text"] = last_word["Text"] + word["Content"]
Contributor guide
Research direction
Start at pca-aws-sf-process-turn-by-turn.py, especially create_turn_by_turn_segments around line 787, and trace how segmentConfidence is populated before punctuation is handled. Confirm the empty-list case no longer raises IndexError and that punctuation handling remains correct for non-empty lists.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, python
- Domain
- backend, cloud
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100