Changeset 33105

Show
Ignore:
Timestamp:
24.05.2019 00:16:49 (4 weeks ago)
Author:
davidb
Message:

Some initial work in support Essentia computed audio features using Python bindings

Location:
gs2-extensions/music-ir-src/trunk
Files:
2 added
1 modified

Legend:

Unmodified
Added
Removed
  • gs2-extensions/music-ir-src/trunk/perllib/plugins/MusicIRPlugin.pm

    r28549 r33105  
    2727package MusicIRPlugin; 
    2828 
    29 use BasePlugin; 
     29use BaseImporter; 
    3030use jAudioExtractor; 
    3131use jSongMinerExtractor; 
     32use pEssentiaExtractor; 
    3233 
    3334use strict; 
     
    3839 
    3940sub BEGIN { 
    40     @MusicIRPlugin::ISA = ('BasePlugin', 'jAudioExtractor', 'jSongMinerExtractor'); 
     41    @MusicIRPlugin::ISA = ('BaseImporter', 'jAudioExtractor', 'jSongMinerExtractor', 'pEssentiaExtractor'); 
    4142} 
    4243 
     
    4445    [  
    4546      { 'name' => "compute_mir_features", 
    46     'desc' => "{BasePlugin.compute_mir_features}", 
     47    'desc' => "{BaseImporter.compute_mir_features}", 
     48    'type' => "enum", 
     49    'list' => [{'name' => "true",  'desc' => "{common.true}"}, 
     50           {'name' => "false", 'desc' => "{common.false}"}], 
     51    'deft' => "false", 
     52    'reqd' => "no" }, 
     53      { 'name' => "compute_essentia_features", 
     54    'desc' => "{BaseImporter.compute_essentia_features}", 
    4755    'type' => "enum", 
    4856    'list' => [{'name' => "true",  'desc' => "{common.true}"}, 
     
    5159    'reqd' => "no" }, 
    5260      { 'name' => "retrieve_mir_metadata", 
    53     'desc' => "{BasePlugin.retrieve_mir_metadata}", 
     61    'desc' => "{BaseImporter.retrieve_mir_metadata}", 
    5462    'type' => "enum", 
    5563    'list' => [{'name' => "true",  'desc' => "{common.true}"}, 
     
    5866    'reqd' => "no" }, 
    5967      { 'name' => "process_exp", 
    60     'desc' => "{BasePlugin.process_exp}", 
     68    'desc' => "{BaseImporter.process_exp}", 
    6169    'type' => "regexp", 
    6270    'deft' => &get_default_process_exp(), 
     
    8391    my $jae_self = new jAudioExtractor($pluginlist, $inputargs, $hashArgOptLists,1); 
    8492    my $jsme_self = new jSongMinerExtractor($pluginlist, $inputargs, $hashArgOptLists,1); 
    85     my $base_self = new BasePlugin($pluginlist, $inputargs, $hashArgOptLists); 
    86  
    87     my $self = BasePlugin::merge_inheritance($jae_self,$jsme_self,$base_self); 
     93    my $pee_self = new pEssentiaExtractor($pluginlist, $inputargs, $hashArgOptLists,1); 
     94 
     95    my $base_self = new BaseImporter($pluginlist, $inputargs, $hashArgOptLists); 
     96 
     97    my $self = BaseImporter::merge_inheritance($jae_self,$jsme_self,$base_self); 
    8898 
    8999    return bless $self, $class; 
     
    93103    my $self = shift (@_); 
    94104     
    95     return q^(?i)(\.mp3|\.wave?|\.aif[fc]?|\.au|\.snd|\.og[ga])$^;  
     105    return q^(?i)(\.mp3|\.wave?|\.aif[fc]?|\.au|\.snd|\.og[ga]|\.m4a)$^;  
    96106} 
    97107 
     
    103113    $self->jAudioExtractor::begin(@_); 
    104114    $self->jSongMinerExtractor::begin(@_); 
     115    $self->pEssentiaExtractor::begin(@_); 
    105116} 
    106117 
     
    132143    } 
    133144 
     145    if ($self->{'compute_essentia_features'} eq "true") 
     146    { 
     147    my $utf8_filename_no_path = $self->filepath_to_utf8($filename_no_path); 
     148    my $url_encoded_filename = &util::rename_file($utf8_filename_no_path, $self->{'file_rename_method'}); 
     149     
     150    my $features_filename = $self->compute_essentia_features($filename_full_path); 
     151    my ($features_ext) = ($features_filename =~ m/\.([^.]+)$/); 
     152 
     153     
     154    my $mime_type = ($features_ext eq "json") ? "application/json" : "text/plain"; 
     155    $doc_obj->associate_file($features_filename, "pessentia.$features_ext",  
     156                 $mime_type, $top_section); 
     157 
     158    } 
     159 
    134160} 
    135161