Skip to content

Instantly share code, notes, and snippets.

@thepycoach
Created January 26, 2022 23:44
Show Gist options
  • Select an option

  • Save thepycoach/f0672bb163706aeedf76991a862ab6bb to your computer and use it in GitHub Desktop.

Select an option

Save thepycoach/f0672bb163706aeedf76991a862ab6bb to your computer and use it in GitHub Desktop.
# STEP 1: UPLOAD YOUR AUDIO FILE AND GET URL
import requests
filename = '/Users/frankandrade/Desktop/Steve Jobs.mp3' # Your path goes here
api_key = # Your API key goes here
upload_endpoint = 'https://api.assemblyai.com/v2/upload'
def read_file(filename, chunk_size=5242880):
with open(filename, 'rb') as f:
while True:
data = f.read(chunk_size)
if not data:
break
yield data
headers = {'authorization': api_key,
'content-type': 'application/json'}
response = requests.post(upload_endpoint,
headers=headers,
data=read_file(filename))
audio_url = response.json()['upload_url']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment