Skip to main content

简单的音乐键检测

项目描述

穆舍

构建状态 PyPI 版本

简单的音乐键检测。

目录

快速开始

安装

pip install musher 

文档

示例使用

我应该使用什么密钥配置文件?

安装

您可以选择以 2 种方式安装此软件包,Python 和 C++。该包最初是用 C++ 编写的,并用 Python 包装。选择以下安装方法之一。

Python 3.5+

pip install musher

C++ 14

依赖项

制作

-- MacOS --
brew install cmake

-- Linux --
sudo apt install cmake

-- Windows --
Download from https://cmake.org/download/

柯南

pip install conan

安装(在制品)

conan install musher

用法

import os
import musher

audio_file_path = os.path.join("data", "audio_files", "mozart_c_major_30sec.wav")
wav_decoded = musher.decode_wav_from_file(audio_file_path)
print(wav_decoded)
{'avg_bitrate_kbps': 1411,
 'bit_depth': 16,
 'channels': 2,
 'file_type': 'wav',
 'length_in_seconds': 30.0,
 'mono': False,
 'normalized_samples': array([
       [ 0.        ,  0.        ,  0.        , ..., -0.33203125, -0.32833862, -0.3274536 ],
       [ 0.        ,  0.        ,  0.        , ..., -0.29162598, -0.27130127, -0.25457764]
    ], dtype=float32),
 'sample_rate': 44100,
 'samples_per_channel': 1323000,
 'stereo': True}

normalized_samples = wav_decoded["normalized_samples"]
sample_rate = wav_decoded["sample_rate"]
# Different key profiles produce different results.
# 'Temperley' produces good results for classical music.
key_profile_type = "Temperley"
key_output = musher.detect_key(normalized_samples, sample_rate, key_profile_type)
print(key_output)
{'first_to_second_relative_strength': 0.6078072169442225,
 'key': 'C',
 'scale': 'major',
 'strength': 0.7603224296919142}

关键配置文件

所有可用密钥配置文件的描述

发展

Python

正常安装

pip install .
# OR
python3 setup.py install

以调试模式安装

pip install -e .
# OR
python3 setup.py develop

注意:这个包有 2 个依赖项:Pybind11Numpy。如果 setup.py 没有为您安装这些 python 包,您可能需要安装这些包。

C++

正常构建

python setup.py cmake

# OR

mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build .

在调试模式下构建

python setup.py cmake --debug

# OR

mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DENABLE_TESTS=On
cmake --build .

测试

Python

必需的依赖项

pip install tox pytest

运行测试

这将针对源代码的 pip 安装副本运行测试(最好在部署代码之前执行)。

# Running this command does not require pytest to be installed
tox 

这将直接运行测试(最好在修改代码库时进行)。

pytest ./tests -v

C++

必需的依赖项

  1. 谷歌测试(当项目以调试模式构建时,柯南应该为你安装这个。)

运行测试

# Ctest
python setup.py ctest

# OR

# Google test
python setup.py gtest

文档

使用 Doxygen、Breathe 和 Sphinx 生成文档。

链接到文档

依赖项

  1. Doxygen >1.5.1 - 生成 C++ 文档
  2. 呼吸- 将 Doxygen 文档翻译成 Sphinx 文档
  3. Sphinx - 生成 python 文档
  4. C++ 依赖项- 构建项目所必需的

如何生成

python setup.py cmake --docs

发布到 Github 页面

在运行此命令之前,您必须安装 python 模块并生成文档。

  1. pip install -e .
  2. 生成文档
python setup.py publish_docs -m "Added docs for new function"

清理

这将删除在构建和测试此包时创建的所有临时文件/文件夹。

python setup.py clean

有用的链接

Python 音频库:

学分

Essentia - 用于音频和音乐分析、描述和合成的 C++ 库,包括 Python 绑定。

下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

musher-0.0.4.tar.gz (36.4 MB 查看哈希

已上传 source

内置发行版

musher-0.0.4-pp37-pypy37_pp73-win32.whl (191.1 kB 查看哈希

已上传 pp37

musher-0.0.4-pp37-pypy37_pp73-manylinux2010_x86_64.whl (293.9 kB 查看哈希

已上传 pp37

musher-0.0.4-pp36-pypy36_pp73-win32.whl (191.1 kB 查看哈希

已上传 pp36

musher-0.0.4-pp36-pypy36_pp73-manylinux2010_x86_64.whl (293.8 kB 查看哈希

已上传 pp36

musher-0.0.4-cp39-cp39-win_amd64.whl (230.4 kB 查看哈希

已上传 cp39

musher-0.0.4-cp39-cp39-win32.whl (192.6 kB 查看哈希

已上传 cp39

musher-0.0.4-cp39-cp39-manylinux2010_x86_64.whl (4.3 MB 查看哈希

已上传 cp39

musher-0.0.4-cp39-cp39-manylinux2010_i686.whl (4.1 MB 查看哈希

已上传 cp39

musher-0.0.4-cp39-cp39-macosx_10_12_x86_64.whl (282.3 kB 查看哈希

已上传 cp39

musher-0.0.4-cp38-cp38-win_amd64.whl (230.1 kB 查看哈希

已上传 cp38

musher-0.0.4-cp38-cp38-win32.whl (192.3 kB 查看哈希

已上传 cp38

musher-0.0.4-cp38-cp38-manylinux2010_x86_64.whl (4.3 MB 查看哈希

已上传 cp38

musher-0.0.4-cp38-cp38-manylinux2010_i686.whl (4.2 MB 查看哈希

已上传 cp38

musher-0.0.4-cp38-cp38-macosx_10_12_x86_64.whl (282.7 kB 查看哈希

已上传 cp38

musher-0.0.4-cp37-cp37m-win_amd64.whl (231.7 kB 查看哈希

已上传 cp37

musher-0.0.4-cp37-cp37m-win32.whl (194.2 kB 查看哈希

已上传 cp37

musher-0.0.4-cp37-cp37m-manylinux2010_x86_64.whl (4.4 MB 查看哈希

已上传 cp37

musher-0.0.4-cp37-cp37m-manylinux2010_i686.whl (4.2 MB 查看哈希

已上传 cp37

musher-0.0.4-cp37-cp37m-macosx_10_12_x86_64.whl (278.8 kB 查看哈希

已上传 cp37

musher-0.0.4-cp36-cp36m-win_amd64.whl (231.5 kB 查看哈希

已上传 cp36

musher-0.0.4-cp36-cp36m-win32.whl (194.0 kB 查看哈希

已上传 cp36

musher-0.0.4-cp36-cp36m-manylinux2010_x86_64.whl (4.4 MB 查看哈希

已上传 cp36

musher-0.0.4-cp36-cp36m-manylinux2010_i686.whl (4.2 MB 查看哈希

已上传 cp36

musher-0.0.4-cp36-cp36m-macosx_10_12_x86_64.whl (278.7 kB 查看哈希

已上传 cp36

musher-0.0.4-cp35-cp35m-win_amd64.whl (231.5 kB 查看哈希

已上传 cp35

musher-0.0.4-cp35-cp35m-win32.whl (194.0 kB 查看哈希

已上传 cp35

musher-0.0.4-cp35-cp35m-manylinux2010_x86_64.whl (4.4 MB 查看哈希

已上传 cp35

musher-0.0.4-cp35-cp35m-manylinux2010_i686.whl (4.2 MB 查看哈希

已上传 cp35

musher-0.0.4-cp35-cp35m-macosx_10_12_x86_64.whl (275.5 kB 查看哈希

已上传 cp35