Skip to content

list index out of range #332

@jrodriguez-development

Description

@jrodriguez-development

[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"]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions