Skip to content

Instantly share code, notes, and snippets.

@wfng92
Created June 10, 2021 09:52
Show Gist options
  • Save wfng92/a9e616ae6adecab4327eeae2a1f57f65 to your computer and use it in GitHub Desktop.
Save wfng92/a9e616ae6adecab4327eeae2a1f57f65 to your computer and use it in GitHub Desktop.
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