Comments (3)
I ran 2to3 before running main.py
E:\tmp>2to3 AudioCompare-master -w
RefactoringTool: Skipping optional fixer: buffer
RefactoringTool: Skipping optional fixer: idioms
RefactoringTool: Skipping optional fixer: set_literal
RefactoringTool: Skipping optional fixer: ws_comma
RefactoringTool: Refactored AudioCompare-master\FFT.py
--- AudioCompare-master\FFT.py (original)
+++ AudioCompare-master\FFT.py (refactored)
@@ -63,7 +63,7 @@
Pxx = np.zeros((numFreqs, n), np.complex_)
# do the ffts of the slices
- for i in xrange(n):
+ for i in range(n):
thisX = x[ind[i]:ind[i]+NFFT]
thisX = windowVals * thisX
fx = np.fft.fft(thisX, n=NFFT)
RefactoringTool: No changes to AudioCompare-master\InputFile.py
RefactoringTool: Refactored AudioCompare-master\Matcher.py
--- AudioCompare-master\Matcher.py (original)
+++ AudioCompare-master\Matcher.py (refactored)
@@ -79,7 +79,7 @@
chunks = len(freq_chunks)
fingerprints = np.zeros(chunks, dtype=np.uint32)
# Examine each chunk independently
- for chunk in xrange(chunks):
+ for chunk in range(chunks):
fingerprint = 0
for bucket in range(BUCKETS):
start_index = bucket * BUCKET_SIZE
@@ -197,7 +197,7 @@
to ChunkInfo objects."""
master = defaultdict(list)
for f in files:
- for chunk in xrange(len(f.fingerprints)):
+ for chunk in range(len(f.fingerprints)):
hash = f.fingerprints[chunk]
master[hash].append(ChunkInfo(chunk, f.filename))
@@ -239,7 +239,7 @@
file_match_offsets[f] = defaultdict(lambda: 0)
# For each chunk in the query file
- for query_chunk_index in xrange(len(file.fingerprints)):
+ for query_chunk_index in range(len(file.fingerprints)):
# See if that chunk's fingerprint is in our master hash
chunk_fingerprint = file.fingerprints[query_chunk_index]
if chunk_fingerprint in master_hash:
@@ -262,7 +262,7 @@
# hash keys were found with the same time difference
# relative to each other.
if len(offsets) != 0:
- max_offset = max(offsets.viewvalues())
+ max_offset = max(offsets.values())
else:
max_offset = 0
@@ -326,19 +326,19 @@
# If there was an error in fingerprinting a file,
# add a special ErrorResult to our results list
- results.extend(filter(lambda x: not x.success, dir1_results))
- results.extend(filter(lambda x: not x.success, dir2_results))
+ results.extend([x for x in dir1_results if not x.success])
+ results.extend([x for x in dir2_results if not x.success])
# Proceed only with fingerprints that were computed
# successfully
- dir1_successes = filter(lambda x: x.success and x.file_len > 0, dir1_results)
- dir2_successes = filter(lambda x: x.success and x.file_len > 0, dir2_results)
+ dir1_successes = [x for x in dir1_results if x.success and x.file_len > 0]
+ dir2_successes = [x for x in dir2_results if x.success and x.file_len > 0]
# Empty files should match other empty files
# Our matching algorithm will not report these as a match,
# so we have to make a special case for it.
- dir1_empty_files = filter(lambda x: x.success and x.file_len == 0, dir1_results)
- dir2_empty_files = filter(lambda x: x.success and x.file_len == 0, dir2_results)
+ dir1_empty_files = [x for x in dir1_results if x.success and x.file_len == 0]
+ dir2_empty_files = [x for x in dir2_results if x.success and x.file_len == 0]
# Every empty file should match every other empty file
for empty_file1, empty_file2 in itertools.product(dir1_empty_files, dir2_empty_files):
@@ -350,8 +350,8 @@
# Get the combined sizes of the files in our two search
# paths
- dir1_size = sum(dir1_file_lengths.viewvalues())
- dir2_size = sum(dir2_file_lengths.viewvalues())
+ dir1_size = sum(dir1_file_lengths.values())
+ dir2_size = sum(dir2_file_lengths.values())
# Whichever search path has more data in it is the
# one we want to put in the master hash, and then query
RefactoringTool: No changes to AudioCompare-master\common.py
RefactoringTool: Refactored AudioCompare-master\error.py
--- AudioCompare-master\error.py (original)
+++ AudioCompare-master\error.py (refactored)
@@ -2,11 +2,11 @@
def die(msg):
- print >> sys.stderr, "ERROR: {e}".format(e=msg)
+ print("ERROR: {e}".format(e=msg), file=sys.stderr)
exit(1)
def warn(msg):
- print >> sys.stderr, "ERROR: {e}".format(e=msg)
+ print("ERROR: {e}".format(e=msg), file=sys.stderr)
RefactoringTool: Refactored AudioCompare-master\main.py
--- AudioCompare-master\main.py (original)
+++ AudioCompare-master\main.py (refactored)
@@ -37,7 +37,7 @@
code = 1
warn(match.message)
else:
- print match
+ print(match)
return code
RefactoringTool: No changes to AudioCompare-master\test\A5Test.py
RefactoringTool: No changes to AudioCompare-master\test\BlackBox.py
RefactoringTool: No changes to AudioCompare-master\test\InputFileTest.py
RefactoringTool: No changes to AudioCompare-master\test\ProfTest.py
RefactoringTool: Refactored AudioCompare-master\test\TestCommon.py
--- AudioCompare-master\test\TestCommon.py (original)
+++ AudioCompare-master\test\TestCommon.py (refactored)
@@ -93,7 +93,7 @@
foundRegex = -1
currRegex = 0
for errRegex in errRegexes:
- if(not isinstance(errRegex, basestring)):
+ if(not isinstance(errRegex, str)):
compiledErrRegexes = [re.compile(errRegex[0]), re.compile(errRegex[1])]
else:
compiledErrRegexes = [re.compile(errRegex)]
@@ -122,7 +122,7 @@
foundRegex = -1
currRegex = 0
for outRegex in outRegexes:
- if(isinstance(outRegex, basestring)):
+ if(isinstance(outRegex, str)):
outRegex = [outRegex]
compiledOutRegexes = []
@@ -172,7 +172,7 @@
currLine += 1
#Check for extraneous output
- self.assertEquals(len(callOut), 0,
+ self.assertEqual(len(callOut), 0,
msg=name + " - should_produce_errors: STDOUT nonempty (Output line 0) (Expected: Actual:" + callOut + ")");
#Check return code
@@ -215,10 +215,10 @@
currLine += 1
#Check for extraneous output
- self.assertEquals(len(callErr), 0,
+ self.assertEqual(len(callErr), 0,
msg=name + " - should_not_produce_errors: STDERR nonempty (Output line 0) (Expected: Actual:" + callErr + ")");
#Check return code
- self.assertEquals(returnCode, 0,
+ self.assertEqual(returnCode, 0,
msg=name + " - should_not_produce_errors: Return Code Incorrect (Expected:0 Actual:" + str(
returnCode) + ")")
RefactoringTool: Refactored AudioCompare-master\test\scores.py
--- AudioCompare-master\test\scores.py (original)
+++ AudioCompare-master\test\scores.py (refactored)
@@ -10,7 +10,7 @@
msg = "SHOULD NOT MATCH:"
else:
msg = "SHOULD MATCH: "
- print "{m} score:{s}\tlength:{l}\tratio:{r} \t{f}".format(m=msg, s=score, l=length, r=score/length, f=map(os.path.basename, test))
+ print("{m} score:{s}\tlength:{l}\tratio:{r} \t{f}".format(m=msg, s=score, l=length, r=score/length, f=list(map(os.path.basename, test))))
def scores():
testSuiteDir = os.path.dirname(os.path.abspath(__file__)) + "/../test_data/"
RefactoringTool: Refactored AudioCompare-master\test\similaritywav.py
--- AudioCompare-master\test\similaritywav.py (original)
+++ AudioCompare-master\test\similaritywav.py (refactored)
@@ -42,9 +42,9 @@
chunks_x = len(x)/chunksize
chunks_y = len(y)/chunksize
-for i in xrange((chunks_x-1)):
+for i in range((chunks_x-1)):
a.append(np.fft.rfft(x[i*chunksize:(i+1)*chunksize]))
-for i in xrange((chunks_y-1)):
+for i in range((chunks_y-1)):
b.append(np.fft.rfft(y[i*chunksize:(i+1)*chunksize]))
a = np.array(a)
@@ -60,8 +60,8 @@
# so this loop run entire two files compare between the chunks (O(n^2)??)
# if there are over 10 matches of two chunks's similarity is over 90%, we deduce as a match
-for i in xrange(cx):
- for j in xrange(cy):
+for i in range(cx):
+ for j in range(cy):
cor = np.corrcoef(a[i],b[j])
if cor[0][1] >=0.9:
@@ -70,10 +70,10 @@
diffs[diff] += 1
if diffs[diff] >=10:
ok = 1
- print 'match'
+ print('match')
sys.exit()
else:
diffs[diff] = 1
-print 'no match'
+print('no match')
RefactoringTool: Refactored AudioCompare-master\test\visualizer.py
--- AudioCompare-master\test\visualizer.py (original)
+++ AudioCompare-master\test\visualizer.py (refactored)
@@ -1,6 +1,6 @@
import sys
from InputFile import InputFile
-from Tkinter import *
+from tkinter import *
from Matcher import *
import Matcher
from FFT import FFT
@@ -28,8 +28,8 @@
"""
try:
input_file = InputFile(sys.argv[1])
- except IOError, e:
- print ("ERROR: {e}".format(e=e))
+ except IOError as e:
+ print(("ERROR: {e}".format(e=e)))
return
sample_rate_adjust_factor = int(NORMAL_SAMPLE_RATE / input_file.get_sample_rate())
@@ -52,7 +52,7 @@
w.pack()
# for each chunk (which will be the X axis)
for i in range(chunks):
- print i
+ print(i)
# for each line (the Y axis)
for line in range(1, lines):
# compute what color this frequency should
RefactoringTool: Files that were modified:
RefactoringTool: AudioCompare-master\FFT.py
RefactoringTool: AudioCompare-master\InputFile.py
RefactoringTool: AudioCompare-master\Matcher.py
RefactoringTool: AudioCompare-master\common.py
RefactoringTool: AudioCompare-master\error.py
RefactoringTool: AudioCompare-master\main.py
RefactoringTool: AudioCompare-master\test\A5Test.py
RefactoringTool: AudioCompare-master\test\BlackBox.py
RefactoringTool: AudioCompare-master\test\InputFileTest.py
RefactoringTool: AudioCompare-master\test\ProfTest.py
RefactoringTool: AudioCompare-master\test\TestCommon.py
RefactoringTool: AudioCompare-master\test\scores.py
RefactoringTool: AudioCompare-master\test\similaritywav.py
RefactoringTool: AudioCompare-master\test\visualizer.py
from audiocompare.
open(file,'rb')
from audiocompare.
I'm sorry, I don't know what's going on here. I haven't attempted to support Python 3 since numpy only worked with Python 2 at the time that I made this program.
from audiocompare.
Related Issues (11)
- No such file or directory HOT 1
- ERROR: [WinError 193] %1 is not a valid Win32 application HOT 1
- AudioCompare/lame: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory HOT 1
- 'cp950' codec can't decode byte 0xff in position 45: illegal multibyte sequence
- How to update to Python3 +
- the audio type required in this code? HOT 3
- which fingerprints algorithm did you use? HOT 2
- No such file or directory HOT 12
- Exec format error HOT 4
- Any suggestions on how to make this compatable with OS X? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from audiocompare.