<s> """<STR_LIT>""" <EOL> import getopt <EOL> import sys <EOL> import os <EOL> import time <EOL> import socket <EOL> import subprocess <EOL> try : <EOL> import json <EOL> except ImportError : <EOL> import simplejson as json <EOL> import pyechonest . config as config <EOL> import pyechonest . song as song <EOL> import random <EOL> import math <EOL> sys . path . insert ( <NUM_LIT:0> , "<STR_LIT>" ) <EOL> import fp <EOL> config . CODEGEN_BINARY_OVERRIDE = os . path . abspath ( "<STR_LIT>" ) <EOL> _local_bigeval = { } <EOL> _new_music_files = [ ] <EOL> _new_queries = <NUM_LIT:0> <EOL> _old_queries = <NUM_LIT:0> <EOL> _total_queries = <NUM_LIT:0> <EOL> def decode_to_wav ( decoder , file , target , what , start = - <NUM_LIT:1> , duration = - <NUM_LIT:1> , volume = <NUM_LIT:100> , downsample_to_22 = False , channels = <NUM_LIT:2> , speed_up = False , slow_down = False ) : <EOL> """<STR_LIT>""" <EOL> if start > <NUM_LIT:0> : what . update ( { "<STR_LIT:start>" : start } ) <EOL> if duration > <NUM_LIT:0> : what . update ( { "<STR_LIT>" : duration } ) <EOL> if volume > <NUM_LIT:0> : what . update ( { "<STR_LIT>" : volume } ) <EOL> if downsample_to_22 : what . update ( { "<STR_LIT>" : True } ) <EOL> if channels < <NUM_LIT:2> : what . update ( { "<STR_LIT>" : True } ) <EOL> if ( speed_up ) : what . update ( { "<STR_LIT>" : True } ) <EOL> if ( slow_down ) : what . update ( { "<STR_LIT>" : True } ) <EOL> if decoder == '<STR_LIT>' : <EOL> cmd = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , target ] <EOL> if start > <NUM_LIT:0> : cmd . extend ( [ "<STR_LIT>" , str ( int ( start * <NUM_LIT> / <NUM_LIT> ) ) ] ) <EOL> if duration > <NUM_LIT:0> : cmd . extend ( [ "<STR_LIT>" , str ( int ( duration * <NUM_LIT> / <NUM_LIT> ) ) ] ) <EOL> if volume > <NUM_LIT:0> : cmd . extend ( [ "<STR_LIT>" , str ( int ( ( float ( volume ) / <NUM_LIT> ) * <NUM_LIT> ) ) ] ) <EOL> if downsample_to_22 : cmd . extend ( [ "<STR_LIT>" ] ) <EOL> if channels < <NUM_LIT:2> : cmd . extend ( [ "<STR_LIT>" ] ) <EOL> if speed_up : cmd . extend ( [ "<STR_LIT>" , "<STR_LIT:2>" ] ) <EOL> if slow_down : cmd . extend ( [ "<STR_LIT>" , "<STR_LIT:2>" ] ) <EOL> cmd . append ( file ) <EOL> elif decoder == "<STR_LIT>" : <EOL> cmd = [ "<STR_LIT>" , "<STR_LIT>" , file , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> if start > <NUM_LIT:0> : cmd . extend ( [ "<STR_LIT>" , str ( start ) ] ) <EOL> if duration > <NUM_LIT:0> : cmd . extend ( [ "<STR_LIT>" , str ( duration ) ] ) <EOL> if downsample_to_22 : cmd . extend ( [ "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> if channels < <NUM_LIT:2> : cmd . extend ( [ "<STR_LIT>" , "<STR_LIT:1>" ] ) <EOL> cmd . append ( target ) <EOL> elif decoder == "<STR_LIT>" : <EOL> cmd = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" % target ] <EOL> if start > <NUM_LIT:0> : cmd . extend ( [ "<STR_LIT>" , str ( start ) ] ) <EOL> if duration > <NUM_LIT:0> : cmd . extend ( [ "<STR_LIT>" , str ( duration ) ] ) <EOL> if downsample_to_22 : cmd . extend ( "<STR_LIT>" ) <EOL> if channels < <NUM_LIT:2> : cmd . extend ( [ "<STR_LIT>" ] ) <EOL> cmd . append ( file ) <EOL> elif decoder == "<STR_LIT>" : <EOL> cmd = [ "<STR_LIT>" , file , target ] <EOL> if start < <NUM_LIT:0> : start = <NUM_LIT:0> <EOL> cmd . extend ( [ "<STR_LIT>" , str ( start ) ] ) <EOL> if duration > <NUM_LIT:0> : cmd . extend ( [ str ( duration ) ] ) <EOL> if downsample_to_22 : cmd . extend ( [ "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> if channels < <NUM_LIT:2> : cmd . extend ( [ "<STR_LIT>" , "<STR_LIT:1>" ] ) <EOL> if speed_up : cmd . extend ( [ "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> if slow_down : cmd . extend ( [ "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> else : <EOL> return ( what , None ) <EOL> """<STR_LIT>""" <EOL> subprocess . Popen ( cmd , stderr = subprocess . PIPE ) . communicate ( ) <EOL> return ( what , target ) <EOL> def munge ( file , start = - <NUM_LIT:1> , duration = - <NUM_LIT:1> , bitrate = <NUM_LIT> , volume = - <NUM_LIT:1> , downsample_to_22 = False , speed_up = False , slow_down = False , lowpass_freq = - <NUM_LIT:1> , encode_to = "<STR_LIT>" , decoder = "<STR_LIT>" , channels = <NUM_LIT:2> ) : <EOL> """<STR_LIT>""" <EOL> me = "<STR_LIT>" + str ( random . randint ( <NUM_LIT:1> , <NUM_LIT> ) ) + "<STR_LIT>" <EOL> what = { "<STR_LIT>" : decoder } <EOL> ( what , me ) = decode_to_wav ( decoder , file , me , what , start , duration , volume , downsample_to_22 , channels , speed_up , slow_down ) <EOL> if not os . path . exists ( me ) : <EOL> print >> sys . stderr , "<STR_LIT>" <EOL> return ( None , what ) <EOL> file_size = os . path . getsize ( me ) <EOL> if ( file_size < <NUM_LIT> ) : <EOL> print >> sys . stderr , "<STR_LIT>" <EOL> os . remove ( me ) <EOL> return ( None , what ) <EOL> roughly_in_seconds = file_size / <NUM_LIT> <EOL> what . update ( { "<STR_LIT>" : roughly_in_seconds } ) <EOL> if encode_to == "<STR_LIT>" : <EOL> what . update ( { "<STR_LIT>" : "<STR_LIT:none>" , "<STR_LIT>" : "<STR_LIT>" } ) <EOL> return ( me , what ) <EOL> if encode_to == "<STR_LIT>" : <EOL> what . update ( { "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" } ) <EOL> cmd = "<STR_LIT>" + str ( bitrate ) + "<STR_LIT:U+0020>" <EOL> if ( lowpass_freq > <NUM_LIT:0> ) : <EOL> what . update ( { "<STR_LIT>" : lowpass_freq } ) <EOL> cmd = cmd + "<STR_LIT>" + str ( lowpass_freq ) + "<STR_LIT:U+0020>" <EOL> what . update ( { "<STR_LIT>" : bitrate } ) <EOL> cmd = cmd + me + "<STR_LIT:U+0020>" + me + "<STR_LIT>" <EOL> if encode_to == "<STR_LIT>" : <EOL> what . update ( { "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" } ) <EOL> cmd = "<STR_LIT>" + me + "<STR_LIT>" + str ( bitrate ) + "<STR_LIT>" + me + "<STR_LIT>" <EOL> if encode_to == "<STR_LIT>" : <EOL> what . update ( { "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" } ) <EOL> cmd = "<STR_LIT>" + me + "<STR_LIT>" + str ( bitrate ) + "<STR_LIT>" + me + "<STR_LIT>" <EOL> os . system ( cmd ) <EOL> try : <EOL> os . remove ( me ) <EOL> except OSError : <EOL> return ( None , what ) <EOL> return ( me + "<STR_LIT:.>" + encode_to , what ) <EOL> def prf ( numbers_dict ) : <EOL> precision = recall = f = true_negative_rate = accuracy = <NUM_LIT:0> <EOL> tp = float ( numbers_dict [ "<STR_LIT>" ] ) <EOL> tn = float ( numbers_dict [ "<STR_LIT>" ] ) <EOL> fp = float ( numbers_dict [ "<STR_LIT>" ] ) + float ( numbers_dict [ "<STR_LIT>" ] ) <EOL> fn = float ( numbers_dict [ "<STR_LIT>" ] ) <EOL> if tp or fp : <EOL> precision = tp / ( tp + fp ) <EOL> if fn or tp : <EOL> recall = tp / ( tp + fn ) <EOL> if precision or recall : <EOL> f = <NUM_LIT> * ( precision * recall ) / ( precision + recall ) <EOL> if tn or fp : <EOL> true_negative_rate = tn / ( tn + fp ) <EOL> if tp or tn or fp or fn : <EOL> accuracy = ( tp + tn ) / ( tp + tn + fp + fn ) <EOL> print "<STR_LIT>" % ( precision , recall , f , true_negative_rate , accuracy , str ( numbers_dict ) ) <EOL> return { "<STR_LIT>" : precision , "<STR_LIT>" : recall , "<STR_LIT:f>" : f , "<STR_LIT>" : true_negative_rate , "<STR_LIT>" : accuracy } <EOL> def dpwe ( numbers_dict ) : <EOL> car = far = frr = pr = <NUM_LIT:0> <EOL> r1 = float ( numbers_dict [ "<STR_LIT>" ] ) <EOL> r2 = float ( numbers_dict [ "<STR_LIT>" ] ) <EOL> r3 = float ( numbers_dict [ "<STR_LIT>" ] ) <EOL> r4 = float ( numbers_dict [ "<STR_LIT>" ] ) <EOL> r5 = float ( numbers_dict [ "<STR_LIT>" ] ) <EOL> if r1 or r2 or r3 : <EOL> car = r1 / ( r1 + r2 + r3 ) <EOL> if r4 or r5 : <EOL> far = r4 / ( r4 + r5 ) <EOL> if r1 or r2 or r3 : <EOL> frr = ( r2 + r3 ) / ( r1 + r2 + r3 ) <EOL> pr = ( ( _old_queries / _total_queries ) * frr ) + ( ( _new_queries / _total_queries ) * far ) <EOL> print "<STR_LIT>" % ( pr , car , far , frr , str ( numbers_dict ) ) <EOL> stats = { } <EOL> stats . update ( numbers_dict ) <EOL> dpwe_nums = { "<STR_LIT>" : pr , "<STR_LIT>" : car , "<STR_LIT>" : far , "<STR_LIT>" : frr } <EOL> stats . update ( dpwe_nums ) <EOL> return dpwe_nums <EOL> def test_file ( filename , local = False , expect_match = True , original_TRID = None , remove_file = True ) : <EOL> """<STR_LIT>""" <EOL> matching_TRID = None <EOL> if filename is None : <EOL> return "<STR_LIT>" <EOL> try : <EOL> if not local : <EOL> query_obj = song . util . codegen ( filename , start = - <NUM_LIT:1> , duration = - <NUM_LIT:1> ) <EOL> s = fp . best_match_for_query ( query_obj [ <NUM_LIT:0> ] [ "<STR_LIT:code>" ] ) <EOL> if s . TRID is not None : <EOL> matching_TRID = s . TRID <EOL> else : <EOL> query_obj = song . util . codegen ( filename , start = - <NUM_LIT:1> , duration = - <NUM_LIT:1> ) <EOL> s = fp . best_match_for_query ( query_obj [ <NUM_LIT:0> ] [ "<STR_LIT:code>" ] , local = local ) <EOL> if s . TRID is not None : <EOL> matching_TRID = s . TRID <EOL> except IOError : <EOL> print "<STR_LIT>" <EOL> return "<STR_LIT>" <EOL> except TypeError : <EOL> return "<STR_LIT>" <EOL> if remove_file : <EOL> if os . path . exists ( filename ) : <EOL> os . remove ( filename ) <EOL> else : <EOL> return "<STR_LIT>" <EOL> if s is not None : <EOL> if len ( s ) > <NUM_LIT:0> : <EOL> if expect_match : <EOL> if original_TRID == matching_TRID : <EOL> return "<STR_LIT>" <EOL> else : <EOL> return "<STR_LIT>" <EOL> else : <EOL> return "<STR_LIT>" <EOL> else : <EOL> if expect_match : <EOL> return "<STR_LIT>" <EOL> else : <EOL> return "<STR_LIT>" <EOL> else : <EOL> return "<STR_LIT>" <EOL> def test_single ( filename , local = False , ** munge_kwargs ) : <EOL> """<STR_LIT>""" <EOL> ( new_file , what ) = munge ( filename , ** munge_kwargs ) <EOL> query_obj = song . util . codegen ( new_file , start = - <NUM_LIT:1> , duration = - <NUM_LIT:1> ) <EOL> s = fp . best_match_for_query ( query_obj [ <NUM_LIT:0> ] [ "<STR_LIT:code>" ] , local = local ) <EOL> if s . TRID is not None : <EOL> if local : <EOL> metad = _local_bigeval [ s . TRID ] <EOL> else : <EOL> metad = fp . metadata_for_track_id ( s . TRID ) <EOL> metad [ "<STR_LIT:title>" ] = metad [ "<STR_LIT>" ] <EOL> song_metadata = { "<STR_LIT>" : metad . get ( "<STR_LIT>" , "<STR_LIT>" ) , "<STR_LIT>" : metad . get ( "<STR_LIT>" , "<STR_LIT>" ) , "<STR_LIT:title>" : metad . get ( "<STR_LIT:title>" , "<STR_LIT>" ) } <EOL> print str ( song_metadata ) <EOL> else : <EOL> print "<STR_LIT>" <EOL> decoded = fp . decode_code_string ( query_obj [ <NUM_LIT:0> ] [ "<STR_LIT:code>" ] ) <EOL> print str ( len ( decoded . split ( "<STR_LIT:U+0020>" ) ) / <NUM_LIT:2> ) + "<STR_LIT>" <EOL> response = fp . query_fp ( decoded , local = local , rows = <NUM_LIT:15> ) <EOL> if response is not None : <EOL> print "<STR_LIT>" <EOL> tracks = { } <EOL> scores = { } <EOL> for r in response . results : <EOL> trid = r [ "<STR_LIT>" ] . split ( "<STR_LIT:->" ) [ <NUM_LIT:0> ] <EOL> if local : <EOL> metad = _local_bigeval [ trid ] <EOL> else : <EOL> metad = fp . metadata_for_track_id ( trid ) <EOL> metad [ "<STR_LIT:title>" ] = metad [ "<STR_LIT>" ] <EOL> m = { "<STR_LIT>" : metad . get ( "<STR_LIT>" , "<STR_LIT>" ) , "<STR_LIT>" : metad . get ( "<STR_LIT>" , "<STR_LIT>" ) , "<STR_LIT:title>" : metad . get ( "<STR_LIT:title>" , "<STR_LIT>" ) } <EOL> if m is not None : <EOL> actual_match = fp . actual_matches ( decoded , fp . fp_code_for_track_id ( r [ "<STR_LIT>" ] , local = local ) ) <EOL> tracks [ r [ "<STR_LIT>" ] ] = ( m , r [ "<STR_LIT>" ] , actual_match ) <EOL> scores [ r [ "<STR_LIT>" ] ] = actual_match <EOL> else : <EOL> print "<STR_LIT>" + r [ "<STR_LIT>" ] <EOL> sorted_scores = sorted ( scores . iteritems ( ) , key = lambda ( k , v ) : ( v , k ) , reverse = True ) <EOL> for ( trackid , score ) in sorted_scores : <EOL> ( m , score , actual_match ) = tracks [ trackid ] <EOL> print trackid + "<STR_LIT>" + str ( int ( score ) ) + "<STR_LIT:U+002CU+0020>" + str ( actual_match ) + "<STR_LIT>" + m [ "<STR_LIT>" ] + "<STR_LIT>" + m [ "<STR_LIT:title>" ] <EOL> else : <EOL> print "<STR_LIT>" + str ( decoded ) <EOL> os . remove ( new_file ) <EOL> def test ( how_many , diag = False , local = False , no_shuffle = False , ** munge_kwargs ) : <EOL> """<STR_LIT>""" <EOL> results = { "<STR_LIT>" : <NUM_LIT:0> , "<STR_LIT>" : <NUM_LIT:0> , "<STR_LIT>" : <NUM_LIT:0> , "<STR_LIT>" : <NUM_LIT:0> , "<STR_LIT>" : <NUM_LIT:0> , "<STR_LIT>" : <NUM_LIT:0> , "<STR_LIT>" : <NUM_LIT:0> , "<STR_LIT>" : <NUM_LIT:0> , "<STR_LIT>" : <NUM_LIT:0> , "<STR_LIT>" : <NUM_LIT:0> } <EOL> docs_to_test = _local_bigeval . keys ( ) + _new_music_files <EOL> if not no_shuffle : <EOL> random . shuffle ( docs_to_test ) <EOL> for x in docs_to_test : <EOL> if results [ "<STR_LIT>" ] == how_many : <EOL> return results <EOL> if x . startswith ( "<STR_LIT>" ) : <EOL> original_TRID = x <EOL> filename = _local_bigeval [ x ] [ "<STR_LIT:filename>" ] <EOL> ( new_file , what ) = munge ( filename , ** munge_kwargs ) <EOL> result = test_file ( new_file , expect_match = True , original_TRID = x , local = local ) <EOL> else : <EOL> filename = x <EOL> original_TRID = None <EOL> ( new_file , what ) = munge ( filename , ** munge_kwargs ) <EOL> result = test_file ( new_file , expect_match = False , local = local ) <EOL> if result is not "<STR_LIT>" and result is not "<STR_LIT>" : <EOL> print "<STR_LIT>" + filename + "<STR_LIT>" + result + "<STR_LIT>" + str ( original_TRID ) + "<STR_LIT>" + str ( what ) <EOL> if diag and not result . startswith ( "<STR_LIT>" ) : <EOL> test_single ( filename , local = local , ** munge_kwargs ) <EOL> results [ result ] += <NUM_LIT:1> <EOL> results [ "<STR_LIT>" ] += <NUM_LIT:1> <EOL> if results [ "<STR_LIT>" ] % <NUM_LIT:10> == <NUM_LIT:0> : <EOL> dpwe ( results ) <EOL> return results <EOL> def usage ( ) : <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" <EOL> def main ( argv ) : <EOL> global _local_bigeval , _new_music_files <EOL> global _new_queries , _old_queries , _total_queries <EOL> single = None <EOL> how_many = None <EOL> start = <NUM_LIT:0> <EOL> duration = <NUM_LIT:30> <EOL> bitrate = <NUM_LIT> <EOL> volume = - <NUM_LIT:1> <EOL> lowpass = - <NUM_LIT:1> <EOL> decoder = "<STR_LIT>" <EOL> encoder = "<STR_LIT>" <EOL> local = None <EOL> diag = False <EOL> channels = <NUM_LIT:2> <EOL> downsample = False <EOL> decoder = "<STR_LIT>" <EOL> testfile = os . path . join ( os . path . dirname ( __file__ ) , '<STR_LIT>' ) <EOL> newfile = "<STR_LIT>" <EOL> no_shuffle = False <EOL> try : <EOL> opts , args = getopt . getopt ( argv , "<STR_LIT>" , <EOL> [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> except getopt . GetoptError : <EOL> usage ( ) <EOL> sys . exit ( <NUM_LIT:2> ) <EOL> for opt , arg in opts : <EOL> if opt in ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> single = arg <EOL> if opt in ( "<STR_LIT:-c>" , "<STR_LIT>" ) : <EOL> how_many = int ( arg ) <EOL> if opt in ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> start = int ( arg ) <EOL> if opt in ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> duration = int ( arg ) <EOL> if opt in ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> decoder = arg <EOL> if opt in ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> bitrate = int ( arg ) <EOL> if opt in ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> volume = int ( arg ) <EOL> if opt in ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> lowpass = int ( arg ) <EOL> if opt in ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> encoder = arg <EOL> if opt in ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> local = arg <EOL> if opt in ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> diag = True <EOL> if opt in ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> channels = <NUM_LIT:1> <EOL> if opt in ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> downsample = True <EOL> if opt in ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> if not os . path . exists ( arg ) : <EOL> print "<STR_LIT>" % arg <EOL> sys . exit ( <NUM_LIT:2> ) <EOL> config . CODEGEN_BINARY_OVERRIDE = arg <EOL> if opt in ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> newfile = arg <EOL> if opt in ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> testfile = arg <EOL> if opt == "<STR_LIT>" : <EOL> no_shuffle = True <EOL> if opt in ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> usage ( ) <EOL> sys . exit ( <NUM_LIT:2> ) <EOL> if ( single is None ) and ( how_many is None ) : <EOL> print >> sys . stderr , "<STR_LIT>" <EOL> usage ( ) <EOL> sys . exit ( <NUM_LIT:2> ) <EOL> if testfile . lower ( ) == "<STR_LIT:none>" and newfile . lower ( ) == "<STR_LIT:none>" and single is None : <EOL> print >> sys . stderr , "<STR_LIT>" <EOL> sys . exit ( <NUM_LIT:2> ) <EOL> if testfile . lower ( ) == "<STR_LIT:none>" : <EOL> _local_bigeval = { } <EOL> else : <EOL> if not os . path . exists ( testfile ) : <EOL> print >> sys . stderr , "<STR_LIT>" <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> _local_bigeval = json . load ( open ( testfile , '<STR_LIT:r>' ) ) <EOL> if newfile . lower ( ) == "<STR_LIT:none>" or not os . path . exists ( newfile ) : <EOL> _new_music_files = [ ] <EOL> else : <EOL> _new_music_files = open ( newfile , '<STR_LIT:r>' ) . read ( ) . split ( '<STR_LIT:\n>' ) <EOL> _new_queries = float ( len ( _new_music_files ) ) <EOL> _old_queries = float ( len ( _local_bigeval . keys ( ) ) ) <EOL> _total_queries = _new_queries + _old_queries <EOL> if local is None : <EOL> local = False <EOL> else : <EOL> codes = json . load ( open ( local , '<STR_LIT:r>' ) ) <EOL> _reversed_bigeval = dict ( ( _local_bigeval [ k ] , k ) for k in _local_bigeval ) <EOL> code_dict = { } <EOL> tids = { } <EOL> for c in codes : <EOL> fn = c [ "<STR_LIT>" ] [ "<STR_LIT:filename>" ] <EOL> tid = _reversed_bigeval . get ( fn , None ) <EOL> tids [ tid ] = True <EOL> if tid is not None : <EOL> if c . has_key ( "<STR_LIT:code>" ) : <EOL> if len ( c [ "<STR_LIT:code>" ] ) > <NUM_LIT:4> : <EOL> code_dict [ tid ] = fp . decode_code_string ( c [ "<STR_LIT:code>" ] ) <EOL> fp . ingest ( code_dict , local = True ) <EOL> lp = { } <EOL> for r in _local_bigeval . keys ( ) : <EOL> if tids . has_key ( r ) : <EOL> lp [ r ] = _local_bigeval [ r ] <EOL> _local_bigeval = lp <EOL> local = True <EOL> if single is not None : <EOL> test_single ( single , local = local , start = start , duration = duration , bitrate = bitrate , volume = volume , lowpass_freq = lowpass , encode_to = encoder , downsample_to_22 = downsample , channels = channels ) <EOL> else : <EOL> results = test ( how_many , diag = diag , local = local , no_shuffle = no_shuffle , start = start , duration = duration , bitrate = bitrate , volume = volume , lowpass_freq = lowpass , encode_to = encoder , downsample_to_22 = downsample , channels = channels ) <EOL> prf ( results ) <EOL> dpwe ( results ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( sys . argv [ <NUM_LIT:1> : ] ) </s>
