in srf-longrun-job-dataflow/srflongrunjobdataflow.py [0:0]
def stt_parse_response(stt_data):
parse_stt_output_response = {
'filename': stt_data[1],
'transcript': None,
'words': [],
'dlp': [],
}
string_transcript = ''
# get transcript from stt_data
for i in stt_data[0]['response']['results']:
if 'transcript' in i['alternatives'][0]:
string_transcript += str(i['alternatives'][0]['transcript']) + ' '
parse_stt_output_response['transcript'] = string_transcript[:-1] # remove the ending whitespace
for element in stt_data[0]['response']['results']:
for word in element['alternatives'][0]['words']:
parse_stt_output_response['words'].append(
{'word': word['word'], 'startsecs': word['startTime'].strip('s'),
'endsecs': word['endTime'].strip('s')})
return parse_stt_output_response