Skip to content

Commit

Permalink
Use selectedAlternative for 0.0 confidence transcriptions
Browse files Browse the repository at this point in the history
If selectedAlternative is empty the lastChar calculation will fail.
A dummy value is needed.
  • Loading branch information
CGarces committed Jul 6, 2023
1 parent 34cb6a0 commit 46cd13d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions sam-app/lambda_functions/sfComprehendUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,14 @@ def processTranscript(iItems):
transcript['content'] = selectedAlternative
if(len(transcripts)>0):
lastItem = transcripts[len(transcripts)-1]
lastChar = lastItem['content'][len(lastItem['content'])-1]
if (float(transcript['start_time']) - float(lastItem['start_time']) <= 2.0) and (lastChar != '.' and lastChar != ',' and lastChar != '?' and lastChar != ':' and lastChar != '!'):
if len(lastItem['content']) == 0:
lastItem['content'] += ' '+ selectedAlternative
else:
transcripts.append(transcript)
lastChar = lastItem['content'][len(lastItem['content'])-1]
if (float(transcript['start_time']) - float(lastItem['start_time']) <= 2.0) and (lastChar != '.' and lastChar != ',' and lastChar != '?' and lastChar != ':' and lastChar != '!'):
lastItem['content'] += ' '+ selectedAlternative
else:
transcripts.append(transcript)
else:
transcripts.append(transcript)
return transcripts
Expand Down

0 comments on commit 46cd13d

Please sign in to comment.