Skip to content

Commit

Permalink
Finished Stress Detector Python WebService
Browse files Browse the repository at this point in the history
  • Loading branch information
maxmousee committed Oct 1, 2015
1 parent 60c376d commit 26d89f8
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions trunk/Python/StressDetector/StressDetector.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,6 @@ def internalerror():
#return web.internalerror("Bad, bad server. No donut for you.")
return json.dumps({'ok':0, 'errcode': 500})

def Base64Encode(ndarray):
return json.dumps([str(ndarray.dtype),base64.b64encode(ndarray),ndarray.shape])

def Base64Decode(jsonDump):
loaded = json.loads(jsonDump)
dtype = np.dtype(loaded[0])
arr = np.frombuffer(base64.decodestring(loaded[1]),dtype)
if len(loaded) > 2:
return arr.reshape(loaded[2])
return arr

urls = (
'/(.*)', 'processAudio'
)
Expand All @@ -42,17 +31,14 @@ def Base64Decode(jsonDump):

class processAudio:
def POST(self, method_id):
#rate3,dat3 = wavfile.read(os.getcwd() + "/rain_man_driver_8000.wav")
i = web.input()
dat2 = web.data()
dat1 = np.array(json.loads(dat2))
print dat1
rate1 = 8000
#send it using this sample rate or die, your choice
dat2 = dat2[2:-2]
dat1 = np.fromstring(dat2, dtype=int, sep=', ')
rate1 = len(dat1)
myemd = emd.emd(dat1, extrapolation=None, nimfs=8, shifting_distance=0.2)
countZeros = 0
imfCount = len(myemd[0])
print imfCount
if imfCount > 3:
imfCount = imfCount - 1

Expand Down

0 comments on commit 26d89f8

Please sign in to comment.