summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2017-07-02 06:40:42 +0200
committerJules Laplace <julescarbon@gmail.com>2017-07-02 06:40:42 +0200
commitef0d6a05a1717b9cb9b52fca9285c9ba8c191b0c (patch)
tree94954b6f983d636ea9744ab600e42c07ce7af735
parentbe26f182ccdff4f96c52d419deebee4aff055e18 (diff)
process aiff spectrum
-rw-r--r--lib/worker/processFiles.js2
-rw-r--r--migrations/20170628233613_createFiles.js2
-rw-r--r--package.json3
-rw-r--r--python/spectrum.py4
4 files changed, 6 insertions, 5 deletions
diff --git a/lib/worker/processFiles.js b/lib/worker/processFiles.js
index fd97928..26fdb0e 100644
--- a/lib/worker/processFiles.js
+++ b/lib/worker/processFiles.js
@@ -78,8 +78,8 @@ function cacheFfprobe(file, fullPath) {
return new Promise ( (resolve, reject) => {
console.log('ffprobe')
ffprobe(fullPath, function(err, probeData) {
- // console.log(probeData)
file.set('duration', probeData.format.duration)
+ file.set('analysis', JSON.stringify(probeData))
resolve()
})
})
diff --git a/migrations/20170628233613_createFiles.js b/migrations/20170628233613_createFiles.js
index eeaa8b3..9801cb3 100644
--- a/migrations/20170628233613_createFiles.js
+++ b/migrations/20170628233613_createFiles.js
@@ -8,7 +8,7 @@ exports.up = function(knex, Promise) {
table.string('mime')
table.string('type')
table.float('duration')
- // table.integer('sample_rate')
+ table.text('analysis')
// table.integer('channels')
table.integer('size')
table.boolean('processed')
diff --git a/package.json b/package.json
index 760c234..aaf33d7 100644
--- a/package.json
+++ b/package.json
@@ -6,7 +6,8 @@
"scripts": {
"start": "babel-node index.js --presets es2015,stage-2",
"test": "mocha test/ --recursive",
- "db:reset": "knex migrate:rollback ; knex migrate:latest"
+ "db:reset": "knex migrate:rollback ; knex migrate:latest",
+ "worker": "node lib/worker"
},
"author": "jules laplace <julescarbon@gmail.com>",
"license": "UNLICENSED",
diff --git a/python/spectrum.py b/python/spectrum.py
index 514092b..267f368 100644
--- a/python/spectrum.py
+++ b/python/spectrum.py
@@ -13,8 +13,8 @@ FILENAME = sys.argv[1]
N_FFT = 2048
def read_audio_spectum(filename):
- fs, x = scipy.io.wavfile.read(filename)
- S = librosa.stft(numpy.transpose(x)[0], N_FFT)
+ x, fs = librosa.load(filename, 44100)
+ S = librosa.stft(x, N_FFT)
S = numpy.log1p(numpy.abs(S))
return S, fs