Skip to content
Snippets Groups Projects
Commit 9c017d42 authored by ale's avatar ale
Browse files

resolve merge conflict

parents 7d187c96 ae835481
No related branches found
No related tags found
No related merge requests found
...@@ -76,6 +76,7 @@ def _vector_from_file(path): ...@@ -76,6 +76,7 @@ def _vector_from_file(path):
tnet.updControl('mrs_natural/inSamples', factor * 512) tnet.updControl('mrs_natural/inSamples', factor * 512)
tnet.tick() tnet.tick()
return tnet.getControl('mrs_realvec/processedData').to_realvec() return tnet.getControl('mrs_realvec/processedData').to_realvec()
...@@ -84,26 +85,13 @@ def vector_from_file(path): ...@@ -84,26 +85,13 @@ def vector_from_file(path):
return _vector_from_file(mp3_path) return _vector_from_file(mp3_path)
if __name__ == '__main__': def main():
import sys, time, marsyas_utils import sys, marsyas_utils
result = vector_from_file(sys.argv[1]) result = vector_from_file(sys.argv[1])
print str(result)[:512]
print 'serialization benchmark...'
n = 5000
start = time.time()
for i in xrange(n):
rstr = marsyas_utils.serialize_realvec(result) rstr = marsyas_utils.serialize_realvec(result)
end = time.time() sys.stdout.write(rstr)
print 'serialization speed: %g iter/sec' % (n / (end - start))
start = time.time()
for i in xrange(n):
result2 = marsyas_utils.deserialize_realvec(rstr)
end = time.time()
print 'deserialization speed: %g iter/sec' % (n / (end - start))
if __name__ == '__main__':
main()
...@@ -9,19 +9,24 @@ from djrandom import utils ...@@ -9,19 +9,24 @@ from djrandom import utils
from djrandom.model.mp3 import MP3 from djrandom.model.mp3 import MP3
from djrandom.database import Session, init_db from djrandom.database import Session, init_db
from djrandom.model import processor from djrandom.model import processor
from djrandom.mood import feature_extraction
from djrandom.mood import marsyas_utils
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
# We run extract_features as an external program because Marsyas has
# a nasty tendency to leak memory during analysis...
def get_features(path):
pipe = subprocess.Popen(['djrandom-mood-extract-features', path],
stdout=subprocess.PIPE)
return pipe.communicate()[0]
class TimbreFeatureExtractor(processor.Processor): class TimbreFeatureExtractor(processor.Processor):
def process(self, mp3): def process(self, mp3):
log.info('extracting features from %s' % mp3.sha1) log.info('extracting features from %s' % mp3.sha1)
try: try:
timbre_vector = feature_extraction.vector_from_file(mp3.path) vector_str = get_features(mp3.path)
vector_str = marsyas_utils.serialize_realvec(timbre_vector)
except Exception, e: except Exception, e:
log.error('error processing %s: %s' % (mp3.sha1, e)) log.error('error processing %s: %s' % (mp3.sha1, e))
return return
......
...@@ -34,6 +34,7 @@ setup( ...@@ -34,6 +34,7 @@ setup(
"djrandom-solr-fixer = djrandom.model.verify:main", "djrandom-solr-fixer = djrandom.model.verify:main",
"djrandom-mood-scanner = djrandom.mood.mood_scanner:main", "djrandom-mood-scanner = djrandom.mood.mood_scanner:main",
"djrandom-mood-db = djrandom.mood.mood_db:main", "djrandom-mood-db = djrandom.mood.mood_db:main",
"djrandom-mood-extract-features = djrandom.mood.feature_extraction:main",
], ],
}, },
) )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment