├── models ├── .DS_Store ├── genre_test.history └── mood_test.history ├── web_demonstrator ├── spinner.gif ├── audio-commons-logo-horizontal.png ├── freesound.js └── index.html ├── music_extractor_profile.yaml ├── Dockerfile ├── LICENSE_apache2 ├── README.md ├── analyze.py └── LICENSE_agpl3 /models/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AudioCommons/ac-audio-extractor/HEAD/models/.DS_Store -------------------------------------------------------------------------------- /models/genre_test.history: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AudioCommons/ac-audio-extractor/HEAD/models/genre_test.history -------------------------------------------------------------------------------- /models/mood_test.history: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AudioCommons/ac-audio-extractor/HEAD/models/mood_test.history -------------------------------------------------------------------------------- /web_demonstrator/spinner.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AudioCommons/ac-audio-extractor/HEAD/web_demonstrator/spinner.gif -------------------------------------------------------------------------------- /music_extractor_profile.yaml: -------------------------------------------------------------------------------- 1 | highlevel: 2 | compute: 1 3 | svm_models: ['/models/genre_test.history', '/models/mood_test.history'] -------------------------------------------------------------------------------- /web_demonstrator/audio-commons-logo-horizontal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AudioCommons/ac-audio-extractor/HEAD/web_demonstrator/audio-commons-logo-horizontal.png -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.6.8-stretch 2 | 3 | # Common requirements 4 | RUN apt-get update \ 5 | && apt-get install -y \ 6 | libyaml-0-2 \ 7 | libfftw3-3 \ 8 | libtag1v5 \ 9 | libsamplerate0 \ 10 | libavcodec57 \ 11 | libavformat57 \ 12 | libavutil55 \ 13 | libavresample3 \ 14 | python3 \ 15 | python3-numpy \ 16 | libpython3.5 \ 17 | python3-yaml \ 18 | python3-six \ 19 | libsndfile1 \ 20 | pkg-config \ 21 | swig \ 22 | && rm -rf /var/lib/apt/lists/* 23 | 24 | 25 | # Python dependencies (needed for essentia) 26 | RUN pip install numpy==1.14.5 27 | 28 | 29 | # Gaia 30 | # See https://github.com/MTG/gaia 31 | RUN apt-get update \ 32 | && apt-get install -y \ 33 | build-essential \ 34 | python \ 35 | libqt4-dev \ 36 | libyaml-dev \ 37 | python-dev \ 38 | && git clone https://github.com/MTG/gaia /tmp/gaia \ 39 | && cd /tmp/gaia \ 40 | && git checkout v2.4.5 \ 41 | && python2 ./waf configure \ 42 | && python2 ./waf \ 43 | && python2 ./waf install \ 44 | && cd / && rm -r /tmp/gaia 45 | 46 | 47 | # Essentia (checkout freesound_extractor_update branch at specific commit) 48 | RUN apt-get update \ 49 | && apt-get install -y \ 50 | build-essential \ 51 | libyaml-dev \ 52 | libfftw3-dev \ 53 | libavcodec-dev \ 54 | libavformat-dev \ 55 | libavutil-dev \ 56 | libavresample-dev \ 57 | python-dev \ 58 | libsamplerate0-dev \ 59 | libtag1-dev \ 60 | python3-numpy-dev \ 61 | git \ 62 | && mkdir /essentia && cd /essentia && git clone https://github.com/MTG/essentia.git \ 63 | && cd /essentia/essentia && git checkout 0ddaedd3ba8988ae759cc746ff7e4ad995dcfeae \ 64 | && ./waf configure --with-examples --with-python --with-gaia \ 65 | && ./waf && ./waf install && ldconfig \ 66 | && apt-get remove -y \ 67 | build-essential \ 68 | libyaml-dev \ 69 | libfftw3-dev \ 70 | libavcodec-dev \ 71 | libavformat-dev \ 72 | libavutil-dev \ 73 | libavresample-dev \ 74 | python3-dev \ 75 | libsamplerate0-dev \ 76 | libtag1-dev \ 77 | python3-numpy-dev \ 78 | && apt-get autoremove -y \ 79 | && apt-get clean -y \ 80 | && rm -rf /var/lib/apt/lists/* \ 81 | && cd / && rm -rf /essentia/essentia 82 | 83 | 84 | # Install ffmpeg (NOTE: this could be probably optimized using libav from above) 85 | RUN apt-get update && apt-get install -y ffmpeg 86 | 87 | # Extra python dependencies 88 | RUN pip install SoundFile==0.10.2 librosa==0.6.1 scipy==1.1.0 ffmpeg-python==0.1.17 89 | RUN pip install rdflib==4.2.2 rdflib-jsonld==0.4.0 PyLD==1.0.3 90 | 91 | # Install version 0.4 (commit be443e54f5b8865d7a055e438545f139899d17bc) of timbral models 92 | RUN git clone https://github.com/AudioCommons/timbral_models.git && cd timbral_models && git checkout be443e54f5b8865d7a055e438545f139899d17bc && python setup.py install # Using commit corresponding to v0.5 (D5.8) 93 | 94 | # Add high-level models and music extractor configuration 95 | RUN mkdir -p models 96 | ADD models /models 97 | ADD music_extractor_profile.yaml / 98 | 99 | # Add analysis script 100 | ADD analyze.py / 101 | ENTRYPOINT [ "python", "/analyze.py" ] 102 | -------------------------------------------------------------------------------- /LICENSE_apache2: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {2018} {Andy Pearce} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Audio Commons Audio Extractor 2 | 3 | The Audio Commons Audio Extractor is a tool for analyzing audio files and extract both music properties (for music samples and music pieces) as well as high-level non-musical properties (timbre models). See [this blog post](https://www.audiocommons.org/2018/07/15/audio-commons-audio-extractor.html) for further details about the Audio Commons Audio Extractor. 4 | 5 | To facilitate its usage, the tool has been *dockerized* and should run efforlessly in any platform with [Docker](https://www.docker.com/) installed. Below you'll find some instructions for running the tool as well as the full list of included audio features. 6 | 7 | Checkout the [web demonstrator](http://www.audiocommons.org/ac-audio-extractor/web_demonstrator/) that shows the power of some of the music properties extracted with this tool. 8 | 9 | ## License 10 | 11 | The Audio Commons Audio Extractor is licensed under AGPLv3 except for the included [timbral models](https://github.com/AudioCommons/timbral_models) code which is licensed under Apache 2. Both license files are included in this source code repository. 12 | 13 | 14 | ## Running the audio extractor 15 | 16 | The Audio Commons Audio Extractor is expected to be used as a command line tool and run from a terminal. Assuming you have Docker installed, you can easily analyze an audio file using the following command (the audio file must be located in the same folder from where you run the command, be aware that the first time you run this command it will take a lot of time as Docker will need to download the actual Audio Commons Audio Extractor tool first): 17 | 18 | ``` 19 | docker run -it --rm -v `pwd`:/tmp mtgupf/ac-audio-extractor:v3 -i /tmp/audio.wav -o /tmp/analysis.json -st 20 | ``` 21 | 22 | The example above mounts the current directory ``pwd`` in the virtual `tmp` directory inside Docker. The output file `audio.json` is also written in `tmp`, and therefore appears in the current directory. You can also mount different volumes and specify paths for input audio and analysis output using the following command (read the [Docker volumes](https://docs.docker.com/storage/volumes/) documentation for more information): 23 | 24 | ``` 25 | docker run -it --rm -v /local/path/to/your/audio/file.wav:/audio.wav -v /local/path/to/output_directory/:/outdir mtgupf/ac-audio-extractor:v3 -i /audio.wav -o /outdir/analysis.json -st 26 | ``` 27 | 28 | You can also run the analysis on several files contained in a directory by entering directories as input and output arguments to the extractor. For instance, you can use the following command: 29 | 30 | ``` 31 | docker run -it --rm -v /local/path/to/your/input_directory/:/audio -v /local/path/to/output_directory/:/outdir mtgupf/ac-audio-extractor:v3 -i /audio/ -o /outdir/ -st 32 | ``` 33 | 34 | You can use the `--help` flag with the Audio Commons Audio Extractor so see a complete list of all available options: 35 | 36 | ``` 37 | docker run -it --rm -v `pwd`:/tmp mtgupf/ac-audio-extractor:v3 --help 38 | 39 | uusage: analyze.py [-h] [-v] [-t] [-m] [-s] -i INPUT -o OUTPUT [-f FORMAT] 40 | [-u URI] 41 | 42 | Audio Commons Audio Extractor (v3). Analyzes a given audio file and writes 43 | results to a JSON file. 44 | 45 | optional arguments: 46 | -h, --help show this help message and exit 47 | -v, --verbose if set, prints detailed info on screen during the 48 | analysis 49 | -t, --timbral-models include descriptors computed from timbral models 50 | -m, --music-pieces include descriptors designed for music pieces 51 | -s, --music-samples include descriptors designed for music samples 52 | -i INPUT, --input INPUT 53 | input audio file or input directory containing the audio files to analyze 54 | -o OUTPUT, --output OUTPUT 55 | output analysis file or output directory where the analysis files will be saved 56 | -f FORMAT, --format FORMAT 57 | format of the output analysis file ("json" or 58 | "jsonld", defaults to "jsonld") 59 | -u URI, --uri URI URI for the analyzed sound (only used if "jsonld" 60 | format is chosen) 61 | ``` 62 | 63 | Note that you can use the flags `t`, `m` and `s` to enable or disable the computation of some specific audio features. 64 | 65 | 66 | ## Output formats 67 | 68 | The Audio Commons audio extractor can write the analysis output to a **JSON** file with a flat hierarchy, or generate a structured output in **JSON-LD** ([JSON for linked data](https://json-ld.org/)). You can choose the format to use with the `--format` argument. By default `format` is set to `jsonld`. When using JSON-LD, you can optionally specify a URI for the analyzed sound resource so that the triples added in the graph are referenced to that URI. For that, use the `--uri` argument. Bellow are example outputs for the JSON and JSON-LD formats. 69 | 70 | 71 | ### JSON output example 72 | ``` 73 | { 74 | "duration": 6.0, 75 | "lossless": 1.0, 76 | "codec": "pcm_s16le", 77 | "bitrate": 705600.0, 78 | "samplerate": 44100.0, 79 | "channels": 1.0, 80 | "audio_md5": "8da67c9c2acbd13998c9002aa0f60466", 81 | "loudness": -28.207069396972656, 82 | "dynamic_range": 0.6650657653808594, 83 | "temporal_centroid": 0.5078766345977783, 84 | "log_attack_time": 0.30115795135498047, 85 | "filesize": 529278, 86 | "single_event": false, 87 | "tonality": "G# minor", 88 | "tonality_confidence": 0.2868785858154297, 89 | "loop": true, 90 | "tempo": 120, 91 | "tempo_confidence": 1.0, 92 | "note_midi": 74, 93 | "note_name": "D5", 94 | "note_frequency": 592.681884765625, 95 | "note_confidence": 0.0, 96 | "brightness": 50.56954356039029, 97 | "depth": 13.000903137777897, 98 | "metallic": 0.4906048209174263, 99 | "roughness": 0.7237051954207928, 100 | "genre": "Genre B", 101 | "mood": "Mood B" 102 | } 103 | ``` 104 | 105 | 106 | ### JSON-LD output example 107 | 108 | ``` 109 | { 110 | "@context": { 111 | "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#", 112 | "ac": "https://w3id.org/ac-ontology/aco#", 113 | "afo": "https://w3id.org/afo/onto/1.1#", 114 | "afv": "https://w3id.org/afo/vocab/1.1#", 115 | "ebucore": "http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#", 116 | "nfo": "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#" 117 | }, 118 | "@type": "ac:AudioFile", 119 | "ebucore:bitrate": 705600.0, 120 | "ebucore:filesize": 529278, 121 | "ebucore:hasCodec": { 122 | "@type": "ebucore:AudioCodec", 123 | "ebucore:codecId": "pcm_s16le" 124 | }, 125 | "nfo:compressionType": "nfo:losslessCompressionType", 126 | "ac:audioMd5": "8da67c9c2acbd13998c9002aa0f60466", 127 | "ac:availableItemOf": { 128 | "@type": "ac:AudioClip" 129 | }, 130 | "ac:signalAudioFeature": [ 131 | { 132 | "@type": "afv:Loop", 133 | "afo:value": true 134 | }, 135 | { 136 | "@type": "afv:Tempo", 137 | "afo:confidence": 1.0, 138 | "afo:value": 120 139 | }, 140 | { 141 | "@type": "afv:Key", 142 | "afo:confidence": 0.2868785858154297, 143 | "afo:value": "G# minor" 144 | }, 145 | { 146 | "@type": "afv:TemporalCentroid", 147 | "afo:value": 0.5078766345977783 148 | }, 149 | { 150 | "@type": "afv:MIDINote", 151 | "afo:confidence": 0.0, 152 | "afo:value": 74 153 | }, 154 | { 155 | "@type": "afv:Pitch", 156 | "afo:confidence": 0.0, 157 | "afo:value": 592.681884765625 158 | }, 159 | { 160 | "@type": "afv:Loudness", 161 | "afo:value": -28.207069396972656 162 | }, 163 | { 164 | "@type": "afv:Note", 165 | "afo:confidence": 0.0, 166 | "afo:value": "D5" 167 | }, 168 | { 169 | "@type": "afv:LogAttackTime", 170 | "afo:value": 0.30115795135498047 171 | } 172 | ], 173 | "ac:signalChannels": 1, 174 | "ac:signalDuration": 6.0, 175 | "ac:singalSamplerate": 44100.0 176 | } 177 | ``` 178 | 179 | 180 | ## Build the docker image locally 181 | 182 | There is no need to build the Docker image locally because Docker will automatically retrieve the image from the remote [Docker Hub](https://hub.docker.com). However, if you need a custom version of the image you can also build it locally using the instructions in the `Dockerfile` of this repository. Use the following command: 183 | 184 | ``` 185 | docker build -t mtgupf/ac-audio-extractor:v3 . 186 | ``` 187 | 188 | ### Pushing the image to MTG's Docker Hub 189 | 190 | The pre-built image for the Audio Commons annotations tools is hosted in [MTG](http://mtg.upf.edu/)'s Docker Hub account. To push a new version of the image use the following command (and change the tag if needed): 191 | 192 | ``` 193 | docker push mtgupf/ac-audio-extractor:v3 194 | ``` 195 | 196 | This is only meant for the admins/maintainers of the image. You'll need a Docker account with wrtie access to MTG's Docker Hub space. 197 | 198 | 199 | ## Included audio features 200 | 201 | ### Audio file properties 202 | 203 | These audio features are always computed and include: 204 | 205 | - ```duration```: Duration of audio file in seconds. 206 | - ```lossless```: Whether audio file is in lossless codec (true or false). 207 | - ```codec```: Audio codec. 208 | - ```bitrate```: Bit rate. 209 | - ```samplerate```: Sample rate in Hz. 210 | - ```channels```: Number of audio channels. 211 | - ```audio_md5```: The MD5 checksum of raw undecoded audio payload. It can be used as a unique identifier of audio content. 212 | - ```filesize```: Size of the file in nytes. 213 | 214 | ### Dynamics 215 | 216 | These audio features are always computed and include: 217 | 218 | - ```loudness```: The integrated (overall) loudness (LUFS) measured using the [EBU R128 standard](http://essentia.upf.edu/documentation/reference/std_LoudnessEBUR128.html). 219 | - ```dynamic_range```: Loudness range (dB, LU) measured using the [EBU R128 standard](http://essentia.upf.edu/documentation/reference/std_LoudnessEBUR128.html). 220 | - ```temporal_centroid```: Temporal centroid (sec.) of the audio signal. It is the point in time in a signal that is a temporal balancing point of the sound event energy. 221 | - ```log_attack_time```: The [log (base 10) of the attack time](http://essentia.upf.edu/documentation/reference/std_LogAttackTime.html) of a signal envelope. The attack time is defined as the time duration from when the sound becomes perceptually audible to when it reaches its maximum intensity. 222 | - ```single_event```: Whether the audio file contains one single *audio event* or more than one (true or false). This computation is based on the loudness of the signal and does not do any frequency analysis. 223 | 224 | ### Music samples and music pieces 225 | 226 | These audio features are only computed when using the `-m` or `-s` flags and include: 227 | 228 | - ```tempo```: BPM value estimated by beat tracking algorithm. 229 | - ```tempo_confidence```: Reliability of the tempo estimation above (in a range between 0 and 1). 230 | - ```loop```: Whether audio file is *loopable* (true or false). 231 | - ```tonality```: Key value estimated by key detection algorithm. 232 | - ```tonality_confidence```: Reliability of the key estimation above (in a range between 0 and 1). 233 | 234 | 235 | ### Music samples 236 | 237 | These audio features are only computed when using the `-s` flag and include: 238 | 239 | - ```note_name```: Pitch note name based on median of estimated fundamental frequency. 240 | - ```note_midi```: MIDI value corresponding to the estimated note. 241 | - ```note_frequency```: Frequency corresponding to the estimated note. 242 | - ```note_confidence```: Reliability of the note name/midi/frequency estimation above (in a range between 0 and 1). 243 | 244 | 245 | ### Music pieces 246 | 247 | These audio features are only computed when using the `-m` flag and include: 248 | 249 | - ```genre```: Music genre of the analysed music track (not yet implemented). 250 | - ```mood```: Mood estimation for the analysed music track (not yet implemented). 251 | 252 | 253 | ### Timbre models 254 | 255 | As described in [deliverable D5.2](https://www.audiocommons.org/assets/files/AC-WP5-SURREY-D5.2%20First%20prototype%20of%20timbral%20characterisation%20tools%20for%20semantically%20annotating%20non-musical%20content.pdf), a number of timbre models have been developed and are included in this tool. Timbre models estimate perceptual qualities of the sounds which tend to be quite subjective and ill-defined. These audio features are only computed when using the `-t` flag and include: 256 | 257 | - ```brightness```: brightness of the analyzed audio in a scale from [0-100]. A *bright* sound is one that is clear/vibrant and/or contains significant high-pitched elements. 258 | - ```hardness```: hardness of the analyzed audio in a scale from [0-100]. A *hard* sound is one that conveys the sense of having been made (i) by something solid, firm or rigid; or (ii) with a great deal of force. 259 | - ```depth```: depth of the analyzed audio in a scale from [0-100]. A *deep* sound is one that conveys the sense of having been made far down below the surface of its source. 260 | - ```roughness```: roughness of the analyzed audio in a scale from [0-100]. A *rough* sound is one that has an uneven or irregular sonic texture. 261 | - ```boominess```: bominess of the analyzedn sound in a scale from [0-100]. A *boomy* sound is one that conveys a sense of loudness, depth and resonance. 262 | - ```warmth```: warmth of the analyzedn sound in a scale from [0-100]. A *warm* sound is one that promotes a sensation analogous to that caused by a physical increase in temperature. 263 | - ```sharpness```: sharpness of the analyzedn sound in a scale from [0-100]. A *sharp* sound is one that suggests it might cut if it were to take on physical form. 264 | - ```reverb```: will return `true` if the signal has reverb or `false` otherwise. 265 | -------------------------------------------------------------------------------- /web_demonstrator/freesound.js: -------------------------------------------------------------------------------- 1 | (function () { 2 | 3 | var freesound = function () { 4 | var authHeader = ''; 5 | var clientId = ''; 6 | var clientSecret = ''; 7 | var host = 'freesound.org'; 8 | 9 | var uris = { 10 | base : 'https://'+host+'/apiv2', 11 | textSearch : '/search/text/', 12 | contentSearch: '/search/content/', 13 | combinedSearch : '/sounds/search/combined/', 14 | sound : '/sounds//', 15 | soundAnalysis : '/sounds//analysis/', 16 | similarSounds : '/sounds//similar/', 17 | comments : '/sounds//comments/', 18 | download : '/sounds//download/', 19 | upload : '/sounds/upload/', 20 | describe : '/sounds//describe/', 21 | pending : '/sounds/pending_uploads/', 22 | bookmark : '/sounds//bookmark/', 23 | rate : '/sounds//rate/', 24 | comment : '/sounds//comment/', 25 | authorize : '/oauth2/authorize/', 26 | logout : '/api-auth/logout/', 27 | logoutAuthorize : '/oauth2/logout_and_authorize/', 28 | me : '/me/', 29 | user : '/users//', 30 | userSounds : '/users//sounds/', 31 | userPacks : '/users//packs/', 32 | userBookmarkCategories : '/users//bookmark_categories/', 33 | userBookmarkCategorySounds : '/users//bookmark_categories//sounds/', 34 | pack : '/packs//', 35 | packSounds : '/packs//sounds/', 36 | packDownload : '/packs//download/' 37 | }; 38 | 39 | var makeUri = function (uri, args){ 40 | for (var a in args) {uri = uri.replace(/<[\w_]+>/, args[a]);} 41 | return uris.base+uri; 42 | }; 43 | 44 | var makeRequest = function (uri, success, error, params, wrapper, method, data, content_type){ 45 | if(method===undefined) method='GET'; 46 | if(!error)error = function(e){console.log(e)}; 47 | params = params || {}; 48 | params['format'] = 'json'; 49 | var fs = this; 50 | var parse_response = function (response){ 51 | var data = eval("(" + response + ")"); 52 | success(wrapper?wrapper(data):data); 53 | }; 54 | var paramStr = ""; 55 | for(var p in params){paramStr = paramStr+"&"+p+"="+params[p];} 56 | if (paramStr){ 57 | uri = uri +"?"+ paramStr; 58 | } 59 | console.log(uri); 60 | 61 | if (typeof module !== 'undefined'){ // node.js 62 | var http = require("http"); 63 | var options = { 64 | host: host, 65 | path: uri.substring(uri.indexOf("/",8),uri.length), // first '/' after 'http://' 66 | port: '80', 67 | method: method, 68 | headers: {'Authorization': authHeader} 69 | }; 70 | var req = http.request(options,function(res){ 71 | var result = ''; 72 | res.setEncoding('utf8'); 73 | res.on('data', function (data){ 74 | result += data; 75 | }); 76 | res.on('end', function() { 77 | if([200,201,202].indexOf(res.statusCode)>=0) 78 | success(wrapper?wrapper(data):data); 79 | else 80 | error(data); 81 | }); 82 | }); 83 | req.on('error', error).end(); 84 | } 85 | else{ // browser 86 | var xhr; 87 | try {xhr = new XMLHttpRequest();} 88 | catch (e) {xhr = new ActiveXObject('Microsoft.XMLHTTP');} 89 | 90 | xhr.onreadystatechange = function(){ 91 | if (xhr.readyState === 4 && [200,201,202].indexOf(xhr.status)>=0){ 92 | var data = eval("(" + xhr.responseText + ")"); 93 | if(success) success(wrapper?wrapper(data):data); 94 | } 95 | else if (xhr.readyState === 4 && xhr.status !== 200){ 96 | if(error) error(xhr.statusText); 97 | } 98 | }; 99 | xhr.open(method, uri); 100 | xhr.setRequestHeader('Authorization',authHeader); 101 | if(content_type!==undefined) 102 | xhr.setRequestHeader('Content-Type',content_type); 103 | xhr.send(data); 104 | } 105 | }; 106 | var checkOauth = function(){ 107 | if(authHeader.indexOf("Bearer")==-1) 108 | throw("Oauth authentication required"); 109 | }; 110 | 111 | var makeFD = function(obj,fd){ 112 | if(!fd) 113 | fd = new FormData(); 114 | for (var prop in obj){ 115 | fd.append(prop,obj[prop]) 116 | } 117 | return fd; 118 | }; 119 | 120 | var search = function(options, uri, success, error,wrapper){ 121 | if(options.analysis_file){ 122 | makeRequest(makeUri(uri), success,error,null, wrapper, 'POST',makeFD(options)); 123 | } 124 | else{ 125 | makeRequest(makeUri(uri), success,error,options, wrapper); 126 | } 127 | }; 128 | 129 | var Collection = function (jsonObject){ 130 | var nextOrPrev = function (which,success,error){ 131 | makeRequest(which,success,error,{}, Collection); 132 | }; 133 | jsonObject.nextPage = function (success,error){ 134 | nextOrPrev(jsonObject.next,success,error); 135 | }; 136 | jsonObject.previousPage = function (success,error){ 137 | nextOrPrev(jsonObject.previous,success,error); 138 | }; 139 | jsonObject.getItem = function (idx){ 140 | return jsonObject.results[idx]; 141 | } 142 | 143 | return jsonObject; 144 | }; 145 | 146 | var SoundCollection = function(jsonObject){ 147 | var collection = Collection(jsonObject); 148 | collection.getSound = function (idx){ 149 | return new SoundObject(collection.results[idx]); 150 | }; 151 | return collection; 152 | }; 153 | 154 | var PackCollection = function(jsonObject){ 155 | var collection = Collection(jsonObject); 156 | collection.getPack = function (idx){ 157 | return new PackObject(collection.results[idx]); 158 | }; 159 | return collection; 160 | }; 161 | 162 | var SoundObject = function (jsonObject){ 163 | jsonObject.getAnalysis = function(filter, success, error, showAll){ 164 | var params = {all: showAll?1:0}; 165 | makeRequest(makeUri(uris.soundAnalysis,[jsonObject.id,filter?filter:""]),success,error); 166 | }; 167 | 168 | jsonObject.getSimilar = function (success, error, params){ 169 | makeRequest(makeUri(uris.similarSounds,[jsonObject.id]),success,error, params,SoundCollection); 170 | }; 171 | 172 | jsonObject.getComments = function (success, error){ 173 | makeRequest(makeUri(uris.comments,[jsonObject.id]),success,error,{},Collection); 174 | }; 175 | 176 | jsonObject.download = function (targetWindow){// can be window, new, or iframe 177 | checkOauth(); 178 | var uri = makeUri(uris.download,[jsonObject.id]); 179 | targetWindow.location = uri; 180 | }; 181 | 182 | jsonObject.comment = function (commentStr, success, error){ 183 | checkOauth(); 184 | var data = new FormData(); 185 | data.append('comment', comment); 186 | var uri = makeUri(uris.comment,[jsonObject.id]); 187 | makeRequest(uri, success, error, {}, null, 'POST', data); 188 | }; 189 | 190 | jsonObject.rate = function (rating, success, error){ 191 | checkOauth(); 192 | var data = new FormData(); 193 | data.append('rating', rating); 194 | var uri = makeUri(uris.rate,[jsonObject.id]); 195 | makeRequest(uri, success, error, {}, null, 'POST', data); 196 | }; 197 | 198 | jsonObject.bookmark = function (name, category,success, error){ 199 | checkOauth(); 200 | var data = new FormData(); 201 | data.append('name', name); 202 | if(category) 203 | data.append("category",category); 204 | var uri = makeUri(uris.bookmark,[jsonObject.id]); 205 | makeRequest(uri, success, error, {}, null, 'POST', data); 206 | }; 207 | 208 | jsonObject.edit = function (description,success, error){ 209 | checkOauth(); 210 | var data = makeFD(description); 211 | var uri = makeUri(uris.edit,[jsonObject.id]); 212 | makeRequest(uri, success, error, {}, null, 'POST', data); 213 | }; 214 | 215 | return jsonObject; 216 | }; 217 | var UserObject = function(jsonObject){ 218 | jsonObject.sounds = function (success, error, params){ 219 | var uri = makeUri(uris.userSounds,[jsonObject.username]); 220 | makeRequest(uri, success, error,params,SoundCollection); 221 | }; 222 | 223 | jsonObject.packs = function (success, error){ 224 | var uri = makeUri(uris.userPacks,[jsonObject.username]); 225 | makeRequest(uri, success, error,{},PackCollection); 226 | }; 227 | 228 | jsonObject.bookmarkCategories = function (success, error){ 229 | var uri = makeUri(uris.userBookmarkCategories,[jsonObject.username]); 230 | makeRequest(uri, success, error); 231 | }; 232 | 233 | jsonObject.bookmarkCategorySounds = function (success, error,params){ 234 | var uri = makeUri(uris.userBookmarkCategorySounds,[jsonObject.username]); 235 | makeRequest(uri, success, error,params); 236 | }; 237 | 238 | return jsonObject; 239 | }; 240 | 241 | var PackObject = function(jsonObject){ 242 | jsonObject.sounds = function (success, error){ 243 | var uri = makeUri(uris.packSounds,[jsonObject.id]); 244 | makeRequest(uri, success, error,{},SoundCollection); 245 | }; 246 | 247 | jsonObject.download = function (targetWindow){// can be current or new window, or iframe 248 | checkOauth(); 249 | var uri = makeUri(uris.packDownload,[jsonObject.id]); 250 | targetWindow.location = uri; 251 | }; 252 | return jsonObject; 253 | }; 254 | 255 | return { 256 | // authentication 257 | setToken: function (token, type) { 258 | authHeader = (type==='oauth' ? 'Bearer ':'Token ')+token; 259 | }, 260 | setClientSecrets: function(id,secret){ 261 | clientId = id; 262 | clientSecret = secret; 263 | }, 264 | 265 | postAccessCode: function(code, success, error){ 266 | var post_url = uris.base+"/oauth2/access_token/" 267 | var data = new FormData(); 268 | data.append('client_id',clientId); 269 | data.append('client_secret',clientSecret); 270 | data.append('code',code); 271 | data.append('grant_type','authorization_code'); 272 | 273 | if (!success){ 274 | success = function(result){ 275 | setToken(result.access_token,'oauth'); 276 | } 277 | } 278 | makeRequest(post_url, success, error, {}, null, 'POST', data); 279 | }, 280 | textSearch: function(query, options, success, error){ 281 | options = options || {}; 282 | options.query = query ? query : " "; 283 | search(options,uris.textSearch,success,error,SoundCollection); 284 | }, 285 | contentSearch: function(options, success, error){ 286 | if(!(options.target || options.analysis_file)) 287 | throw("Missing target or analysis_file"); 288 | search(options,uris.contentSearch,success,error,SoundCollection); 289 | }, 290 | combinedSearch:function(options, success, error){ 291 | if(!(options.target || options.analysis_file || options.query)) 292 | throw("Missing query, target or analysis_file"); 293 | search(options,uris.contentSearch,success,error); 294 | }, 295 | getSound: function(soundId,success, error){ 296 | makeRequest(makeUri(uris.sound, [soundId]), success,error,{}, SoundObject); 297 | }, 298 | 299 | upload: function(audiofile,filename, description, success,error){ 300 | checkOauth(); 301 | var fd = new FormData(); 302 | fd.append('audiofile', audiofile,filename); 303 | if(description){ 304 | fd = makeFD(description,fd); 305 | } 306 | makeRequest(makeUri(uris.upload), success, error, {}, null, 'POST', fd); 307 | }, 308 | describe: function(upload_filename , description, license, tags, success,error){ 309 | checkOauth(); 310 | var fd = makeFD(description); 311 | makeRequest(makeUri(uris.upload), success, error, {}, null, 'POST', fd); 312 | }, 313 | 314 | getPendingSounds: function(success,error){ 315 | checkOauth(); 316 | makeRequest(makeUri(uris.pending), success,error,{}); 317 | }, 318 | 319 | // user resources 320 | me: function(success,error){ 321 | checkOauth(); 322 | makeRequest(makeUri(uris.me), success,error); 323 | }, 324 | 325 | getLoginURL: function(){ 326 | if(clientId===undefined) throw "client_id was not set" 327 | var login_url = makeUri(uris.authorize); 328 | login_url += "?client_id="+clientId+"&response_type=code"; 329 | return login_url; 330 | }, 331 | getLogoutURL: function(){ 332 | var logout_url = makeUri(uris.logoutAuthorize); 333 | logout_url += "?client_id="+clientId+"&response_type=code"; 334 | 335 | return logout_url; 336 | }, 337 | 338 | getUser: function(username, success,error){ 339 | makeRequest(makeUri(uris.user, [username]), success,error,{}, UserObject); 340 | }, 341 | 342 | getPack: function(packId,success,error){ 343 | makeRequest(makeUri(uris.pack, [packId]), success,error,{}, PackObject); 344 | } 345 | } 346 | }; 347 | 348 | // compatible with CommonJS (node), AMD (requireJS) failing back to browser global 349 | // working with node requires web-audio-api module 350 | if (typeof module !== 'undefined') {module.exports = freesound(); } 351 | else if (typeof define === 'function' && typeof define.amd === 'object') { define("freesound", [], freesound); } 352 | else {this.freesound = freesound(); } 353 | }()); 354 | -------------------------------------------------------------------------------- /analyze.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | import json 4 | import math 5 | import hashlib 6 | import subprocess 7 | from pathlib import Path 8 | import numpy as np 9 | import logging 10 | import pyld 11 | import rdflib 12 | import essentia 13 | essentia.log.infoActive = False 14 | essentia.log.warningActive = False 15 | import uuid 16 | import ffmpeg 17 | import warnings 18 | warnings.filterwarnings("ignore") 19 | from essentia.standard import MusicExtractor, FreesoundExtractor, MonoLoader, MonoWriter 20 | from rdflib import Graph, URIRef, BNode, Literal, Namespace, plugin 21 | from rdflib.serializer import Serializer 22 | from rdflib.namespace import RDF 23 | from argparse import ArgumentParser, ArgumentTypeError 24 | import timbral_models 25 | 26 | MORE_THAN_2_CHANNELS_EXCEPTION_MATCH_TEXT = 'Audio file has more than 2 channels' 27 | METADATA_READER_EXCEPTION_MATCH_TEXT = 'pcmMetadata cannot read files which are neither "wav" nor "aiff"' 28 | 29 | logger = logging.getLogger() 30 | 31 | AC = Namespace("https://w3id.org/ac-ontology/aco#") 32 | AFO = Namespace("https://w3id.org/afo/onto/1.1#") 33 | AFV = Namespace("https://w3id.org/afo/vocab/1.1#") 34 | EBU = Namespace("http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#") 35 | NFO = Namespace("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#") 36 | 37 | ac_mapping = { 38 | "duration": "metadata.audio_properties.length", 39 | "lossless": "metadata.audio_properties.lossless", 40 | "codec": "metadata.audio_properties.codec", 41 | "bitrate": "metadata.audio_properties.bit_rate", 42 | "samplerate": "metadata.audio_properties.sample_rate", 43 | "channels": "metadata.audio_properties.number_channels", 44 | "audio_md5": "metadata.audio_properties.md5_encoded", 45 | "loudness": "lowlevel.loudness_ebu128.integrated", 46 | "dynamic_range": "lowlevel.loudness_ebu128.loudness_range", 47 | "temporal_centroid": "sfx.temporal_centroid", 48 | "log_attack_time": "sfx.logattacktime", 49 | } 50 | 51 | def convert_to_wav(audiofile, samplerate=44100): 52 | # Convert to mono WAV using ffmpeg 53 | output_filename = '/tmp/{0}-converted.wav'.format(hashlib.md5(audiofile.encode('utf-8')).hexdigest()) 54 | if not os.path.exists(output_filename): 55 | logger.debug('{0}: converting to WAV'.format(audiofile)) 56 | ffmpeg.input(audiofile).output(output_filename, ac=1).run(quiet=True, overwrite_output=True) 57 | 58 | return output_filename 59 | 60 | def run_freesound_extractor(audiofile): 61 | logger.debug('{0}: running Essentia\'s FreesoundExtractor'.format(audiofile)) 62 | 63 | try: 64 | fs_pool, _ = FreesoundExtractor()(audiofile) 65 | except RuntimeError as e: 66 | if MORE_THAN_2_CHANNELS_EXCEPTION_MATCH_TEXT in str(e) or METADATA_READER_EXCEPTION_MATCH_TEXT in (str(e)): 67 | converted_audiofile = convert_to_wav(audiofile) 68 | fs_pool, _ = FreesoundExtractor()(converted_audiofile) 69 | else: 70 | raise e 71 | return fs_pool 72 | 73 | 74 | def estimate_number_of_events(audiofile, audio, sample_rate=44100, region_energy_thr=0.5, silence_thr_scale=4.5, group_regions_ms=50): 75 | """ 76 | Returns list of activity "onsets" for an audio signal based on its energy envelope. 77 | This is more like "activity detecton" than "onset detection". 78 | """ 79 | logger.debug('{0}: estimating number of sound events'.format(audiofile)) 80 | 81 | def group_regions(regions, group_regions_ms): 82 | """ 83 | Group together regions which are very close in time (i.e. the end of a region is very close to the start of the following). 84 | """ 85 | if len(regions) <= 1: 86 | grouped_regions = regions[:] # Don't do anything if only one region or no regions at all 87 | else: 88 | # Iterate over regions and mark which regions should be grouped with the following regions 89 | to_group = [] 90 | for count, ((at0, at1, a_energy), (bt0, bt1, b_energy)) in enumerate(zip(regions[:-1], regions[1:])): 91 | if bt0 - at1 < group_regions_ms / 1000: 92 | to_group.append(1) 93 | else: 94 | to_group.append(0) 95 | to_group.append(0) # Add 0 for the last one which will never be grouped with next (there is no "next region") 96 | 97 | # Now generate the grouped list of regions based on the marked ones in 'to_group' 98 | grouped_regions = [] 99 | i = 0 100 | while i < len(to_group): 101 | current_group_start = None 102 | current_group_end = None 103 | x = to_group[i] 104 | if x == 1 and current_group_start is None: 105 | # Start current grouping 106 | current_group_start = i 107 | while x == 1: 108 | i += 1 109 | x = to_group[i] 110 | current_group_end = i 111 | grouped_regions.append( (regions[current_group_start][0], regions[current_group_end][1], sum([z for x,y,z in regions[current_group_start:current_group_end+1]]))) 112 | current_group_start = None 113 | current_group_end = None 114 | else: 115 | grouped_regions.append(regions[i]) 116 | i += 1 117 | return grouped_regions 118 | 119 | # Load audio file 120 | t = np.linspace(0, len(audio)/sample_rate, num=len(audio)) 121 | 122 | # Compute envelope and average signal energy 123 | env_algo = essentia.standard.Envelope( 124 | attackTime = 15, 125 | releaseTime = 50, 126 | ) 127 | envelope = env_algo(audio) 128 | average_signal_energy = np.sum(np.array(envelope)**2)/len(envelope) 129 | silence_thr = average_signal_energy * silence_thr_scale 130 | 131 | # Get energy regions above threshold 132 | # Implementation based on https://stackoverflow.com/questions/43258896/extract-subarrays-of-numpy-array-whose-values-are-above-a-threshold 133 | mask = np.concatenate(([False], envelope > silence_thr, [False] )) 134 | idx = np.flatnonzero(mask[1:] != mask[:-1]) 135 | idx -= 1 # Avoid index out of bounds (0-index) 136 | regions = [(t[idx[i]], t[idx[i+1]], np.sum(envelope[idx[i]:idx[i+1]]**2)) for i in range(0, len(idx), 2)] # Energy is a list of tuples like (start_time, end_time, energy) 137 | regions = [region for region in regions if region[2] > region_energy_thr] # Discard those below region_energy_thr 138 | 139 | # Group detected regions that happen close together 140 | regions = group_regions(regions, group_regions_ms) 141 | 142 | return len(regions) # Return number of sound events detected 143 | 144 | 145 | _is_single_event_cache = None 146 | def is_single_event(audiofile, max_duration=7): 147 | ''' 148 | Estimate if the audio signal contains one single event using the 'estimate_number_of_events' 149 | function above. We store the result of 'estimate_number_of_events' in a global variable so 150 | it can be reused in the different calls of 'is_single_event'. 151 | ''' 152 | global _is_single_event_cache 153 | if _is_single_event_cache is None: 154 | sample_rate = 44100 155 | try: 156 | audio_file = MonoLoader(filename=audiofile, sampleRate=sample_rate) 157 | except RuntimeError as e: 158 | if MORE_THAN_2_CHANNELS_EXCEPTION_MATCH_TEXT in str(e): 159 | converted_audiofile = convert_to_wav(audiofile) 160 | audio_file = MonoLoader(filename=converted_audiofile, sampleRate=sample_rate) 161 | audio = audio_file.compute() 162 | if len(audio)/sample_rate > max_duration: 163 | # If file is longer than max duration, we don't consider it to be single event 164 | _is_single_event_cache = False 165 | else: 166 | _is_single_event_cache = estimate_number_of_events(audiofile, audio, sample_rate=sample_rate) == 1 167 | return _is_single_event_cache 168 | 169 | 170 | def ac_general_description(audiofile, fs_pool, ac_descriptors): 171 | logger.debug('{0}: adding basic AudioCommons descriptors'.format(audiofile)) 172 | 173 | # Add Audio Commons descriptors from the fs_pool 174 | for ac_name, essenia_name in ac_mapping.items(): 175 | if fs_pool.containsKey(essenia_name): 176 | value = fs_pool[essenia_name] 177 | ac_descriptors[ac_name] = value 178 | ac_descriptors["filesize"] = os.stat(audiofile).st_size 179 | ac_descriptors["single_event"] = is_single_event(audiofile) 180 | 181 | 182 | def ac_rhythm_description(audiofile, fs_pool, ac_descriptors): 183 | logger.debug('{0}: adding rhythm descriptors'.format(audiofile)) 184 | 185 | IS_LOOP_CONFIDENCE_THRESHOLD = 0.95 186 | is_loop = fs_pool['rhythm.bpm_loop_confidence.mean'] > IS_LOOP_CONFIDENCE_THRESHOLD 187 | ac_descriptors["loop"] = is_loop 188 | 189 | if is_loop: 190 | ac_descriptors["tempo"] = int(round(fs_pool['rhythm.bpm_loop'])) 191 | ac_descriptors["tempo_confidence"] = fs_pool['rhythm.bpm_loop_confidence.mean'] 192 | else: 193 | ac_descriptors["tempo"] = int(round(fs_pool['rhythm.bpm'])) 194 | tempo_confidence = fs_pool['rhythm.bpm_confidence'] / 5.0 # Normalize BPM confidence value to be in range [0, 1] 195 | ac_descriptors["tempo_confidence"] = np.clip(tempo_confidence, 0.0, 1.0) 196 | 197 | return ac_descriptors 198 | 199 | 200 | def ac_tonality_description(audiofile, fs_pool, ac_descriptors): 201 | logger.debug('{0}: adding tonality descriptors'.format(audiofile)) 202 | 203 | key = fs_pool['tonal.key.key'] + " " + fs_pool['tonal.key.scale'] 204 | ac_descriptors["tonality"] = key 205 | ac_descriptors["tonality_confidence"] = fs_pool['tonal.key.strength'] 206 | 207 | 208 | def ac_pitch_description(audiofile, fs_pool, ac_descriptors): 209 | logger.debug('{0}: adding pitch descriptors'.format(audiofile)) 210 | 211 | def midi_note_to_note(midi_note): 212 | # Use convention MIDI value 69 = 440.0 Hz = A4 213 | note = midi_note % 12 214 | octave = midi_note / 12 215 | return '%s%i' % (['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B'][note], octave - 1) 216 | 217 | def frequency_to_midi_note(frequency): 218 | return int(round(69 + (12 * math.log(frequency / 440.0)) / math.log(2))) 219 | 220 | pitch_median = float(fs_pool['lowlevel.pitch.median']) 221 | midi_note = frequency_to_midi_note(pitch_median) 222 | note_name = midi_note_to_note(midi_note) 223 | ac_descriptors["note_midi"] = midi_note 224 | ac_descriptors["note_name"] = note_name 225 | ac_descriptors["note_frequency"] = pitch_median 226 | ac_descriptors["note_confidence"] = float(fs_pool['lowlevel.pitch_instantaneous_confidence.median']) 227 | 228 | 229 | def ac_timbral_models(audiofile, ac_descriptors): 230 | logger.debug('{0}: computing timbral models'.format(audiofile)) 231 | 232 | converted_filename = convert_to_wav(audiofile) 233 | try: 234 | timbre = timbral_models.timbral_extractor(converted_filename, clip_output=True, verbose=False) 235 | timbre['reverb'] = timbre['reverb'] == 1 236 | ac_descriptors.update(timbre) 237 | except Exception as e: 238 | logger.debug('{0}: timbral models computation failed ("{1}")'.format(audiofile, e)) 239 | 240 | 241 | def ac_highlevel_music_description(audiofile, ac_descriptors): 242 | logger.debug('{0}: running Essentia\'s MusicExtractor'.format(audiofile)) 243 | me_pool, _ = MusicExtractor(profile='music_extractor_profile.yaml')(audiofile) 244 | ac_descriptors["genre"] = me_pool['highlevel.genre_test.value'] 245 | ac_descriptors["mood"] = me_pool['highlevel.mood_test.value'] 246 | 247 | 248 | def build_graph(ac_descriptors, uri=None): 249 | 250 | g = Graph() 251 | 252 | audioFile = BNode() 253 | 254 | if uri is None: 255 | availableItemOf = BNode() 256 | else: 257 | availableItemOf = URIRef(uri) 258 | g.add((availableItemOf, RDF['type'], AC['AudioClip'])) 259 | g.add((audioFile, AC['availableItemOf'], availableItemOf)) 260 | 261 | g.add((audioFile, RDF['type'], AC['AudioFile'])) 262 | g.add((audioFile, AC['singalSamplerate'], Literal(ac_descriptors['samplerate']))) 263 | g.add((audioFile, AC['signalChannels'], Literal(int(ac_descriptors['channels'])))) 264 | g.add((audioFile, AC['signalDuration'], Literal(ac_descriptors['duration']))) 265 | g.add((audioFile, EBU['bitrate'], Literal(ac_descriptors['bitrate']))) 266 | g.add((audioFile, EBU['filesize'], Literal(ac_descriptors['filesize']))) 267 | g.add((audioFile, AC['audioMd5'], Literal(ac_descriptors['audio_md5']))) 268 | #g.add((audioFile, AC['singleEvent'], Literal(ac_descriptors['single_event']))) 269 | 270 | audioCodec = BNode() 271 | g.add((audioCodec, RDF['type'], EBU['AudioCodec'])) 272 | g.add((audioCodec, EBU['codecId'], Literal(ac_descriptors['codec']))) 273 | g.add((audioFile, EBU['hasCodec'], audioCodec)) 274 | 275 | if ac_descriptors['lossless']: 276 | g.add((audioFile, NFO['compressionType'], Literal('nfo:losslessCompressionType'))) 277 | else: 278 | g.add((audioFile, NFO['compressionType'], Literal('nfo:lossyCompressionType'))) 279 | 280 | 281 | for type_name, value_field, confidence_field in [ 282 | ('Tempo', 'tempo', 'tempo_confidence'), 283 | ('Loop', 'loop', None), 284 | ('Key', 'tonality', 'tonality_confidence'), 285 | ('Loudness', 'loudness', None), 286 | ('TemporalCentroid', 'temporal_centroid', None), 287 | ('LogAttackTime', 'log_attack_time', None), 288 | ('MIDINote', 'note_midi', 'note_confidence'), 289 | ('Note', 'note_name', 'note_confidence'), 290 | ('Pitch', 'note_frequency', 'note_confidence'), 291 | #('TimbreBrightness', 'brightness', 'note_confidence'), 292 | #('TimbreDepth', 'depth', None), 293 | #('TimbreHardness', 'hardness', None), 294 | #('TimbreMetallic', 'metallic', None), 295 | #('TimbreReverb', 'reverb', None), 296 | #('TimbreRoughness', 'roughness', None), 297 | #('TimbreBoominess', 'booming', None), 298 | #('TimbreWarmth', 'warmth', None), 299 | #('TimbreSharpness', 'sharpness', None), 300 | ]: 301 | if value_field in ac_descriptors: 302 | # Only include descriptors if present in analysis 303 | signalFeature = BNode() 304 | g.add((signalFeature, RDF['type'], AFV[type_name])) 305 | g.add((signalFeature, AFO['value'], Literal(ac_descriptors[value_field]))) 306 | if confidence_field is not None: 307 | g.add((signalFeature, AFO['confidence'], Literal(ac_descriptors[confidence_field]))) 308 | g.add((audioFile, AC['signalAudioFeature'], signalFeature)) 309 | 310 | return g 311 | 312 | 313 | def render_jsonld_output(g): 314 | 315 | def dlfake(input): 316 | '''This is to avoid a bug in PyLD (should be easy to fix and avoid this hack really..)''' 317 | return {'contextUrl': None,'documentUrl': None,'document': input} 318 | 319 | context = { 320 | "rdf": str(RDF), 321 | "ac": str(AC), 322 | "afo": str(AFO), 323 | "afv": str(AFV), 324 | "ebucore": str(EBU), 325 | "nfo": str(NFO), 326 | } 327 | frame = {"@type": str(AC['AudioFile'])} # Apparently just by indicating the frame like this it already builds the desired output 328 | jsonld = g.serialize(format='json-ld', context=context).decode() # this gives us direct triple representation in a compact form 329 | jsonld = pyld.jsonld.frame(jsonld, frame, options={"documentLoader":dlfake}) # this "frames" the JSON-LD doc but it also expands it (writes out full URIs) 330 | jsonld = pyld.jsonld.compact(jsonld, context, options={"documentLoader":dlfake}) # so we need to compact it again (turn URIs into CURIEs) 331 | return jsonld 332 | 333 | 334 | def analyze(audiofile, outfile, compute_timbral_models=False, compute_descriptors_music_pieces=False, compute_descriptors_music_samples=False, out_format="json", uri=None): 335 | logger.info('{0}: starting analysis'.format(audiofile)) 336 | 337 | # Get initial descriptors from Freesound Extractor 338 | fs_pool = run_freesound_extractor(audiofile) 339 | 340 | # Post-process descriptors to get AudioCommons descirptors and compute extra ones 341 | ac_descriptors = dict() 342 | ac_general_description(audiofile, fs_pool, ac_descriptors) 343 | if compute_descriptors_music_pieces or compute_descriptors_music_samples: 344 | ac_tonality_description(audiofile, fs_pool, ac_descriptors) 345 | ac_rhythm_description(audiofile, fs_pool, ac_descriptors) 346 | if compute_descriptors_music_samples: 347 | ac_pitch_description(audiofile, fs_pool, ac_descriptors) 348 | if compute_timbral_models: 349 | MAX_SOUND_DURATION_FOR_TIMBRAL_MODELS = 30 # Avoid computing timbral models for sound longer than 30 seconds to avoid too many slow computations 350 | if ac_descriptors['duration'] < MAX_SOUND_DURATION_FOR_TIMBRAL_MODELS: 351 | ac_timbral_models(audiofile, ac_descriptors) 352 | else: 353 | logger.debug('{0}: skipping computation of timbral models as audio is longer than {1} seconds'.format(audiofile, MAX_SOUND_DURATION_FOR_TIMBRAL_MODELS)) 354 | 355 | if compute_descriptors_music_pieces: 356 | ac_highlevel_music_description(audiofile, ac_descriptors) 357 | 358 | if out_format == 'jsonld': 359 | # Convert output to JSON-LD 360 | graph = build_graph(ac_descriptors, uri=uri) 361 | output = render_jsonld_output(graph) 362 | else: 363 | # By default (or in case of unknown format, use JSON) 364 | output = ac_descriptors 365 | 366 | logger.info('{0}: analysis finished'.format(audiofile)) 367 | json.dump(output, open(outfile, 'w'), indent=4) 368 | 369 | 370 | if __name__ == '__main__': 371 | parser = ArgumentParser(description=""" 372 | Audio Commons Audio Extractor (v3). Analyzes a given audio file and writes results to a JSON file. 373 | """) 374 | parser.add_argument('-v', '--verbose', help='if set, prints detailed info on screen during the analysis', action='store_const', const=True, default=False) 375 | parser.add_argument('-t', '--timbral-models', help='include descriptors computed from timbral models', action='store_const', const=True, default=False) 376 | parser.add_argument('-m', '--music-pieces', help='include descriptors designed for music pieces', action='store_const', const=True, default=False) 377 | parser.add_argument('-s', '--music-samples', help='include descriptors designed for music samples', action='store_const', const=True, default=False) 378 | parser.add_argument('-i', '--input', help='input audio file or input directory containing the audio files to analyze', required=True) 379 | parser.add_argument('-o', '--output', help='output analysis file or output directory where the analysis files will be saved', required=True) 380 | parser.add_argument('-f', '--format', help='format of the output analysis file ("json" or "jsonld", defaults to "jsonld")', default="jsonld") 381 | parser.add_argument('-u', '--uri', help='URI for the analyzed sound (only used if "jsonld" format is chosen)', default=None) 382 | 383 | args = parser.parse_args() 384 | logging.basicConfig(format='%(asctime)s %(levelname)s:%(message)s', level=logging.INFO if not args.verbose else logging.DEBUG) 385 | 386 | # check if input and output arguments point to directories 387 | if os.path.isdir(args.input) and os.path.isdir(args.output): 388 | folder = args.input 389 | input_files = [x for x in Path(folder).iterdir() if x.is_file()] 390 | for input_file in input_files: 391 | output_file = os.path.join(args.output, '{}_analysis.json'.format(input_file.stem)) 392 | analyze(str(input_file), output_file, args.timbral_models, args.music_pieces, args.music_samples, args.format, args.uri) 393 | 394 | # check if input argument points to a file 395 | elif os.path.isfile(args.input): 396 | analyze(args.input, args.output, args.timbral_models, args.music_pieces, args.music_samples, args.format, args.uri) 397 | 398 | else: 399 | raise ArgumentTypeError('Make sure input and output arguments are both files or folders') 400 | -------------------------------------------------------------------------------- /web_demonstrator/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Audio Commons Audio Extractor Web Demonstrator 5 | 6 | 7 | 8 | 9 | 10 | 11 | 79 | 80 | 81 | 82 |
83 | 92 |
93 |
94 |
95 |
96 | Query
97 | 98 |
99 |
100 |
101 |
102 |
103 | Single event 104 |
105 |
106 |
107 | Loop 108 |
109 |
110 |
111 |
112 |
113 | Tonality
114 |
115 |
116 |
117 |
118 |
119 | Tempo
120 |
121 |
122 |
123 |
124 |
125 |
126 | Pitch
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 | Brightness 136 |
137 |
138 |
139 |
140 |
141 | Hardness 142 |
143 |
144 |
145 |
146 |
147 | Depth 148 |
149 |
150 |
151 |
152 |
153 | Roughness 154 |
155 |
156 |
157 |
158 |
159 | Boominess 160 |
161 |
162 |
163 |
164 |
165 | Warmth 166 |
167 |
168 |
169 |
170 |
171 | Sharpness 172 |
173 |
174 |
175 |
176 |
177 | Reverb 178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 | 187 |
188 | 189 |
190 |
191 | 192 | 475 | 476 | 477 | 478 | 479 | -------------------------------------------------------------------------------- /LICENSE_agpl3: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | Audio Commons Audio Extractor 633 | Copyright (C) MTG-UPF 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | --------------------------------------------------------------------------------