From 46cd13d441bd116bd9aeb5dba4356b6b7417f1e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Garc=C3=A9s?= Date: Thu, 6 Jul 2023 14:12:21 +0200 Subject: [PATCH] Use selectedAlternative for 0.0 confidence transcriptions If selectedAlternative is empty the lastChar calculation will fail. A dummy value is needed. --- sam-app/lambda_functions/sfComprehendUtil.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sam-app/lambda_functions/sfComprehendUtil.py b/sam-app/lambda_functions/sfComprehendUtil.py index ee09651..20b27f9 100644 --- a/sam-app/lambda_functions/sfComprehendUtil.py +++ b/sam-app/lambda_functions/sfComprehendUtil.py @@ -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