Created
December 10, 2021 12:41
-
-
Save gmyrianthous/90552235fcdf61704c0916bd9bb9ce9e to your computer and use it in GitHub Desktop.
Sentiment Analysis with AssemblyAI API and Python - Part 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AUDIO_FILE = '/path/to/your/audio/file.mp3' | |
UPLOAD_ENDPOINT = 'https://api.assemblyai.com/v2/upload' | |
def read_audio_file(file): | |
"""Helper method that reads in audio files""" | |
with open(file, 'rb') as f: | |
while True: | |
data = f.read(5242880) | |
if not data: | |
break | |
yield data | |
res_upload = requests.post( | |
UPLOAD_ENDPOINT, | |
headers=headers, | |
data=read_audio_file(AUDIO_FILE) | |
) | |
upload_url = res_upload.json()['upload_url'] | |
""" | |
Example response from AssemblyAI upload endpoint | |
pprint(res_upload.json()) | |
{'upload_url': 'https://cdn.assemblyai.com/upload/b017e8c0-b31a-4d09-9dc2-8dee0ee0d3c8'} | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment