Automated parsing of Amazon-Transcribe-annotated episode transcripts
A couple of days ago, a friend of mine reached out to me with a request.
He had been playing around with the Amazon Transcribe API, in his attempts to have a nicely formatted transcriptions for his podcast episodes.
He was convinced there must've been a way to achieve that via the API, and I have to admit, initially my assumption was the same.
However, nothing useful came up in the docs, neither did I manage to find anything, via a few Google searches, that could do the job for him.
So, I went on to create a small script so that he could turn Amazon's raw JSON annotation, that looks like the one listed in the appendix below, into something that's a bit more human friendly, and makes sense as a companion to the audio clips and show notes of a podcast, e.g.:
Speaker 1: Blah blah blah.
Speaker 2: Oh, I see! Blah blah blah.
Speaker 1: Indeed, you're making a fair point. Blah.
The full listing of the script can be found on my Github page. It is compatible with Python 2.7 and Python 3+.
You just need to populate an input file, called input.txt, where each line is semi-colon-separated and contains the name of the Amazon Transcribe output JSON file, and a comma-separated, ordered list of speakers.
For example, the following input.txt file will result in the iterative processing of files episode_1.json, episode_2.json and episode_3.json. speaker_1, speaker_2 and speaker_3 will replace the automatically generated placeholders spk_0, spk_1 and spk_2.
The output HTML files will be named after the jobName from each input JSON file.
episode_1.json;speaker_1,speaker_2
episode_2.json;speaker_2,speaker_3
episode_3.json;speaker_1,speaker_2,speaker_3
Once you've created your input.txt file and moved it in the same directory as the process_aws_output.py file, you simply need to run the script with Python:
$ python process_aws_output.py
SUCCESS!
A SUCCESS! message is expected, signifying that all HTML outputs have been stored in the same directory.
Please, don't hesitate to ask questions or request changes or improvements via the Issues section.
If you're feeling generous, donations are welcome :)
BTC: 1QFNgTV3GQby8uv3mXwLKBHAgKUEenSREd
ETH: 0xa7350d9fb3c6193759b587bb984f0dfe3568c8ed
LTC: LW3SNJ61CXUfRQTpehpDfV7vv1iVdLh9En
ADA: DdzFFzCqrhtBbS7o5LQ3u1ZxFVz3Q6b2bQ86FEYanf6UsRgK6D3So4grpZEHPXcitQWEuRfnAA7jzi3xmj9Md6kng2UiVn4QLxEsAefK
BCH: 1QFNgTV3GQby8uv3mXwLKBHAgKUEenSREd
Appendix: Amazon Transcribe raw output
{
"jobName": "job ID",
"accountId": "account ID",
"results": {
"transcripts": [{
"transcript": "Professional answer."
}],
"speaker_labels": {
"speakers": 1,
"segments": [{
"start_time": "0.000000",
"speaker_label": "spk_0",
"end_time": "1.430",
"items": [{
"start_time": "0.100",
"speaker_label": "spk_0",
"end_time": "0.690"
}, {
"start_time": "0.690",
"speaker_label": "spk_0",
"end_time": "1.210"
}]
}]
},
"items": [{
"start_time": "0.100",
"end_time": "0.690",
"alternatives": [{
"confidence": "0.8162",
"content": "Professional"
}],
"type": "pronunciation"
}, {
"start_time": "0.690",
"end_time": "1.210",
"alternatives": [{
"confidence": "0.9939",
"content": "answer"
}],
"type": "pronunciation"
}, {
"alternatives": [{
"content": "."
}],
"type": "punctuation"
}]
},
"status": "COMPLETED"
}
✅ @crypto-jeronimo, I gave you an upvote on your first post! Please give me a follow and I will give you a follow in return!
Please also take a moment to read this post regarding bad behavior on Steemit.
Congratulations @crypto-jeronimo! You received a personal award!
You can view your badges on your Steem Board and compare to others on the Steem Ranking
Do not miss the last post from @steemitboard:
Vote for @Steemitboard as a witness to get one more award and increased upvotes!
Congratulations @crypto-jeronimo! You received a personal award!
You can view your badges on your Steem Board and compare to others on the Steem Ranking
Do not miss the last post from @steemitboard:
Vote for @Steemitboard as a witness to get one more award and increased upvotes!