Exemplo n.º 1
0
                     obj.dummy_result = "%s:::%s" % (m.name, 'Unknown')
                 
                 obj.score = res.score
                 
                 
             except Exception, e:
                 print e
                 pass
         
     else:
         print 
         print    
         print "####### TRYING FOR LOOSE MATCHES..."
 
         try:
             code = fp.decode_code_string(code)
             res = fp.query_fp(code)
             
             print res.results
             
             print 'choosen:'
             print res.results[0]
             
             id = res.results[0]['track_id']
             score = res.results[0]['score']
             m = Media.objects.get(pk=id)
             print m
             
             if score > 50:
             
                 obj.dummy_result = "%s : %s" % (m.name, score)
Exemplo n.º 2
0
    def codegen(self):

        print
        print '#####################################################'
        print 'codegen'
        print 'path: %s' % self.path

        try:
           with open(self.path) as f:
               pass
        except IOError as e:
            print "Unable to open file"
            print e
            sys.exit(1)

        print
        print '#####################################################'
        print 'calling ffmpeg'

        p = subprocess.Popen([
            'ffmpeg',
            '-i', self.path,
            '-ac', '1',
            '-ar', '11025',
            '-f', 's16le',
            '-t', '%s' % (REC_DURATION),
            '-ss', '1',
            '-',
        ], stdout=subprocess.PIPE)

        samples = []

        while True:
            sample = p.stdout.read(2)
            if sample == '':
                break
            samples.append(struct.unpack('h', sample)[0] / 32768.0)

        print
        print '#####################################################'
        print 'Some samples (first 10)'
        print samples[0:10]

        data = echoprint.codegen(samples)
        print
        print '#####################################################'
        print 'generated codestring'

        code = data['code']
        print '# code sequence'
        print fp.decode_code_string(code)

        print '# code string'
        print code
        print data['version']

        # calling api...
        if self.lookup:
            print
            print '#####################################################'
            print 'API SAYS...'
            r = requests.get("http://local.openbroadcast.ch:8080/en/api/v1/track/?format=json&code=%s" % code)
            res = r.json()

            print res

            print
            print res['objects'][0]['absolute_url']
Exemplo n.º 3
0
                    except:
                        obj.dummy_result = "%s:::%s" % (m.name, 'Unknown')

                    obj.score = res.score

                except Exception, e:
                    print e
                    pass

        else:
            print
            print
            print "####### TRYING FOR LOOSE MATCHES..."

            try:
                code = fp.decode_code_string(code)
                res = fp.query_fp(code)

                print res.results

                print 'choosen:'
                print res.results[0]

                id = res.results[0]['track_id']
                score = res.results[0]['score']
                m = Media.objects.get(pk=id)
                print m

                if score > 50:

                    obj.dummy_result = "%s : %s" % (m.name, score)