Created
February 8, 2022 15:06
-
-
Save gmyrianthous/26f2ec5b7e4204e12a074b9ed301a459 to your computer and use it in GitHub Desktop.
Topic Detection with Python - Part 2
This file contains hidden or 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