in lambda/indexer/jobcomplete.py [0:0]
def prepare_transcript(transcript_uri):
logger.info(f"prepare_transcript(transcript_uri={transcript_uri[0:100]}...)")
duration_secs=0
response = urllib.request.urlopen(transcript_uri)
transcript = json.loads(response.read())
items = transcript["results"]["items"]
txt = ""
sentence = ""
for i in items:
if (i["type"] == 'punctuation'):
sentence = sentence + i["alternatives"][0]["content"]
if (i["alternatives"][0]["content"] == '.'):
#sentence completed
txt = txt + " " + sentence + " "
sentence = ""
else:
if (sentence == ''):
sentence = "[" + i["start_time"] + "]"
sentence = sentence + " " + i["alternatives"][0]["content"]
duration_secs = i["end_time"]
if (sentence != ""):
txt = txt + " " + sentence + " "
out = textwrap.fill(txt, width=70)
return [duration_secs, out]