diff --git a/server/djrandom/mood/extract_features.py b/server/djrandom/mood/extract_features.py index 5b3a4a30be7a43d04ffe6411f3e1e247e8e26d41..bf9f6e14fcdf0f8578cf9dedad8b3174ca4e8437 100644 --- a/server/djrandom/mood/extract_features.py +++ b/server/djrandom/mood/extract_features.py @@ -14,12 +14,21 @@ from djrandom.mood import mood log = logging.getLogger(__name__) +def vector_from_file(path): + ln = os.path.join('/tmp', '__analysis_%s.mp3' % os.path.basename(path)) + os.symlink(path, ln) + try: + return mood.vector_from_file(ln) + finally: + os.unlink(ln) + + class FeatureExtractor(processor.Processor): def process(self, mp3): log.info('extracting features from %s' % mp3.sha1) try: - timbre_vector = mood.vector_from_file(mp3.path) + timbre_vector = vector_from_file(mp3.path) except Exception, e: log.error('error processing %s: %s' % (mp3.sha1, e)) return diff --git a/server/djrandom/mood/mood.cc b/server/djrandom/mood/mood.cc index c3aa4e2e4f740cce877e0bf7c10cd71808fef42c..df18fb1a1f386e11253890f97d39f8abdf89f552 100644 --- a/server/djrandom/mood/mood.cc +++ b/server/djrandom/mood/mood.cc @@ -104,8 +104,8 @@ string vector_from_file(const string& filename) // Shift the start over so that the duration is in the middle mrs_natural start = (slength - numsamps)/2; - fnet->updctrl("SoundFileSource/src/mrs_natural/start", start); - fnet->updctrl("SoundFileSource/src/mrs_natural/duration", numsamps); + fnet->updctrl("SoundFileSource/src/mrs_natural/pos", start); + fnet->updctrl("SoundFileSource/src/mrs_natural/onSamples", numsamps); // ----------------- Accumulator ---------------------------------