Created
June 10, 2021 09:52
-
-
Save wfng92/a9e616ae6adecab4327eeae2a1f57f65 to your computer and use it in GitHub Desktop.
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
import requests | |
import shutil | |
import uuid | |
def generate_audio_filename(): | |
return f"{uuid.uuid4()}.wav" | |
def download_file(url): | |
local_filename = generate_audio_filename() | |
with requests.get(url, stream=True) as r: | |
with open(generate_audio_filename(), 'wb') as f: | |
shutil.copyfileobj(r.raw, f) | |
return local_filename | |
url = "http://localhost:8000/wav" | |
download_file(url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment