Speech to text using assembly AI

Run this python code to submit the mp3 file from S3. You will have to register first to get the authorization API key.


import requests
headers = {
    “authorization”: “XXX”,
    “content-type”: “application/json”

endpoint = “https://api.assemblyai.com/v2/transcript”
json = {
  “audio_url”: “https://s3-us-west-2.amazonaws.com/blog.assemblyai.com/audio/8-7-2018-post/7510.mp3”
response = requests.post(endpoint, json=json, headers=headers)

You will get id and status like this…

‘id’: ‘g9j4q46h9-5d04-4f96-8186-b4def1b1b65b’, ‘status’: ‘queued’,

Use the id to query the results.

endpoint = “https://api.assemblyai.com/v2/transcript/g9j4q46h9-5d04-4f96-8186-b4def1b1b65b”
response = requests.get(endpoint, headers=headers)

And you will get the text of audio file. It will look something like this…

‘text’: ‘You know, Demons on TV like that. And and for people to expose themselves to being rejected on TV or you know, her M humiliated by fear factor or you know.’

Powered by WPeMatico