Exemplo n.º 1
0
 def testCounts(self):
     msg = sidewalk
     r, t = main.decode(msg, dictfile)
     l = [("there", 4), ("sidewalk", 1), ("and", 5), ("wind", 1),
          ("the", 6)]
     for w, c in l:
         self.assertEqual(t.count(w), c)
Exemplo n.º 2
0
def testRand_DurationHMM():
    '''
    test with audio features from real recording, but some random models_makam, not trained models_makam 
    TODO: this might not work. rewrite
    '''
    durGMMhmm, d = makeTestDurationHMM()

    durGMMhmm.setALPHA(0.97)

    listDurations = [70, 30, 20, 10, 20]
    durGMMhmm.setDurForStates(listDurations)

    observationFeatures = numpy.array((0.6 * numpy.random.random_sample(
        (2, d)) - 0.3),
                                      dtype=numpy.double)
    #     observationFeatures = loadMFCCs(URIrecordingNoExt)

    decode(lyricsWithModels, observationFeatures, 'testRecording')
Exemplo n.º 3
0
def for_decode():
    errors = []
    if 'image' not in request.files:
        errors.append('no image')
    if 'key' not in request.form:
        errors.append('no key')
    if len(errors) > 0:
        return jsonify({'status': 400, 'errors': errors}), 400
    img_data = np.array(Image.open(request.files['image']).convert('RGBA'))
    return jsonify({
        'status': 200,
        'data': decode(img_data, request.form['key'])
    })
Exemplo n.º 4
0
def api():

    print('in')

    postData = request.json
    imgData = postData['imgData']

    #print(imgData)

    dbs = {}

    label, lblname = predict(decode(imgData))
    print(lblname)
    df = pd.read_csv('final.csv', index_col=0)

    indexValues = df.columns.values
    data = df.loc[label]
    dbNames = list(set(indexValues) - set(['label', 'name']))

    for dbName in dbNames:

        db = {}
        ref = pd.read_csv('database-new/' + dbName + '.csv')
        reqId = data[dbName]
        reqData = ref.loc[ref['id'] == reqId]
        #print(reqData)

        for column in reqData:
            if not column == 'image':
                value = reqData[column].tolist()
                if not value == []:
                    value = value[0]
                    #print(type(value))
                    if isinstance(value, long):
                        value = str(value).strip('L')
                    #print(column, value)
                    db[column] = value
        if not db == {}:
            dbs[dbName] = db

    print(dbs)

    return Response(response=json.dumps(dbs),
                    status=200,
                    mimetype="application/json")
Exemplo n.º 5
0
 def testLongSingleShift(self): 
     msg = hamlet_encoded
     res = hamlet
     r, t = main.decode(msg, dictfile)
     self.assertEqual(r, res)
Exemplo n.º 6
0
 def testShortMultiShift(self): 
     msg = cat_encoded
     res = cat
     r, t = main.decode(msg, dictfile)
     self.assertEqual(r, res)
Exemplo n.º 7
0
 def testShortSingleShift(self): 
     msg = sidewalk_encoded
     res = sidewalk
     r, t = main.decode(msg, dictfile)
     self.assertEqual(r, res)
Exemplo n.º 8
0
 def testLongMultiShift(self):
     msg = v_entries_encoded
     res = v_entries
     r, t = main.decode(msg, dictfile)
     self.assertEqual(r, res)
Exemplo n.º 9
0
 def testLongSingleShift(self):
     msg = hamlet_encoded
     res = hamlet
     r, t = main.decode(msg, dictfile)
     self.assertEqual(r, res)
Exemplo n.º 10
0
 def test(self):
     self.assertEqual(decode([20, 12, 18, 30, 21], 1939), "scout")
     self.assertEqual(
         decode([14, 10, 22, 29, 6, 27, 19, 18, 6, 12, 8], 1939),
         "masterpiece")
Exemplo n.º 11
0
 def test_decoding(self):
     assert "WeebLinux" == main.decode("JrroYvahk")
Exemplo n.º 12
0
 def OnButtonClick(self):
     self.labelVariable.set(main.decode(self.entryVariable.get()))
Exemplo n.º 13
0
import main

r = main.encode('some hello')
print(r)
print(main.decode(r))

r = main.encode('我数据库好地方')
print(r)
print(main.decode(r))

r = main.encode('142857')
print(r)
print(main.decode(r))

r = main.encode(r)
print(r)
print(main.decode(r))

code = main.encode('你好啊,123')
print(code)
imdata = main.to_imdata_pixels(code)
print(imdata)
print(main.decode(main.origin_imdata_pixels(imdata)))
Exemplo n.º 14
0
 def test_decode(self):
     self.assertEqual(decode(sourcecode), ["oeko", "tek", "hel", "hum", "laer", "kun"])
Exemplo n.º 15
0
 def testLongMultiShift(self): 
     msg = v_entries_encoded
     res = v_entries
     r, t = main.decode(msg, dictfile)
     self.assertEqual(r, res)
Exemplo n.º 16
0
 def testCounts(self): 
     msg = sidewalk
     r, t = main.decode(msg, dictfile)
     l = [("there",4),("sidewalk",1),("and",5),("wind",1),("the",6)]
     for w,c in l:
         self.assertEqual(t.count(w), c)
Exemplo n.º 17
0
 def testShortSingleShift(self):
     msg = sidewalk_encoded
     res = sidewalk
     r, t = main.decode(msg, dictfile)
     self.assertEqual(r, res)
Exemplo n.º 18
0
 def test(self):
     self.assertEqual(main.decode([[4, 1], 2, [2, 3], [2, 1], 4, [4, 5]]),
                      [1, 1, 1, 1, 2, 3, 3, 1, 1, 4, 5, 5, 5, 5])
Exemplo n.º 19
0
 def testShortMultiShift(self):
     msg = cat_encoded
     res = cat
     r, t = main.decode(msg, dictfile)
     self.assertEqual(r, res)