annotate pyspark/ilm/transform.py @ 0:e34cf1b6fe09 tip

commit
author Daniel Wolff
date Sat, 20 Feb 2016 18:14:24 +0100
parents
children
rev   line source
Daniel@0 1 # Part of DML (Digital Music Laboratory)
Daniel@0 2 #
Daniel@0 3 # This program is free software; you can redistribute it and/or
Daniel@0 4 # modify it under the terms of the GNU General Public License
Daniel@0 5 # as published by the Free Software Foundation; either version 2
Daniel@0 6 # of the License, or (at your option) any later version.
Daniel@0 7 #
Daniel@0 8 # This program is distributed in the hope that it will be useful,
Daniel@0 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Daniel@0 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Daniel@0 11 # GNU General Public License for more details.
Daniel@0 12 #
Daniel@0 13 # You should have received a copy of the GNU General Public
Daniel@0 14 # License along with this library; if not, write to the Free Software
Daniel@0 15 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Daniel@0 16
Daniel@0 17 #!/usr/bin/python
Daniel@0 18 # -*- coding: utf-8 -*-
Daniel@0 19 __author__="hargreavess"
Daniel@0 20 __date__ ="$29-Sep-2014 15:31:01$"
Daniel@0 21
Daniel@0 22 import subprocess
Daniel@0 23 import time
Daniel@0 24 import random
Daniel@0 25 from os import walk
Daniel@0 26
Daniel@0 27 def transform(audio_file, vamp_transform_list, output_dir):
Daniel@0 28 print "transforming " + audio_file
Daniel@0 29
Daniel@0 30 command = ['sonic-annotator']
Daniel@0 31 command.extend(['-T', vamp_transform_list,
Daniel@0 32 audio_file, '-w', 'rdf', '--rdf-force', '--rdf-basedir', output_dir, '--rdf-many-files',
Daniel@0 33 '-w', 'csv', '--csv-force', '--csv-basedir', output_dir])
Daniel@0 34
Daniel@0 35 print "calling subprocess.subprocess.Popen..."
Daniel@0 36 start = time.time()
Daniel@0 37 p = subprocess.Popen(
Daniel@0 38 command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
Daniel@0 39 p.wait()
Daniel@0 40
Daniel@0 41 end = time.time()
Daniel@0 42 print "finished in " + (str)(end-start)
Daniel@0 43
Daniel@0 44 return True
Daniel@0 45