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