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

commit
author Daniel Wolff
date Sat, 20 Feb 2016 18:14:24 +0100
parents
children
line wrap: on
line source
# Part of DML (Digital Music Laboratory)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

#!/usr/bin/python
# -*- coding: utf-8 -*-
__author__="hargreavess"
__date__ ="$29-Sep-2014 15:31:01$"

import subprocess
import time
import random
from os import walk

def transform(audio_file, vamp_transform_list, output_dir):
    print "transforming " + audio_file

    command = ['sonic-annotator']
    command.extend(['-T', vamp_transform_list,
        audio_file, '-w', 'rdf', '--rdf-force', '--rdf-basedir', output_dir, '--rdf-many-files',
        '-w', 'csv', '--csv-force', '--csv-basedir', output_dir])

    print "calling subprocess.subprocess.Popen..."
    start = time.time()
    p = subprocess.Popen(
        command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
    p.wait()

    end = time.time()
    print "finished in " + (str)(end-start)

    return True