from IPython.display import Audio
import scipy.io.wavfile as sciwav

rate, raw = sciwav.read('mary.wav')
Audio(raw, rate=44100)

"""
Explanation: POTS Processing
End of explanation
"""


import filters

pots1 = filters.pots(raw)
Audio(pots1, rate=44100)

"""
Explanation: Local (Python)
Requires Python 2.7-3.x, NumPy, and SciPy
as a Package
End of explanation
"""


import glob
list(glob.glob('*.wav'))

!python dopots.py mary.wav

list(glob.glob('*.wav'))

"""
Explanation: as a Script
End of explanation
"""


import requests
APP_URL = 'https://alpine-cupcake-2461.herokuapp.com/pots/json'

pots2 = requests.post(APP_URL, json=raw.tolist()).json()
#Audio(pots2['data'], rate=44100)

"""
Explanation: Web
Runs via Heroku. Don't hammer it, or it might magically stop working. For everybody.
JSON
POST a 1-D array to https://alpine-cupcake-2461.herokuapp.com/pots/json. Reply is an object with a "data" field that contains the processed 1-D array.
End of explanation
"""


