audio_analysis 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: be4f1696cce0f5398d08f905a45a881fb939ce1e746bed8a943a17e5368473b2
4
- data.tar.gz: 7960769e3356f04183979c3841a4bf891f5d4df4891a74604268be9054ede8ee
3
+ metadata.gz: 4159bea00fd1205a90744b10c3d5075f139af032483239c667db67af8da086d1
4
+ data.tar.gz: 057f3a9d2d6491c4f170ef88aea5b1efc4e8eb0f14b5f93319a5140a6aa0328a
5
5
  SHA512:
6
- metadata.gz: ca7d64ee01c61dc6da85657f74907de1d42748801319b7042670142d6d63ecbfbb53632b7cb485ec5d01478b067da2d872b5be32c76cd31c8b153339ed04c65b
7
- data.tar.gz: 460d3598f041e3527fe1518cc47f66c93e0ff1745d7ff801a5c06a4a973f7e44bd0330e2392c44091e7369f4acae5fe75ae187ad71595443a32a5efc873354c3
6
+ metadata.gz: e5bdc1ef1531bdf30ac1b4b9bfdad306da0f6a0b30099f45fea5fd1a646a560c23900689a0a0ff639846db859844d7552e786107ed3c0ed6cfb0bb766f27c983
7
+ data.tar.gz: 89ea15c38010cb2b8ae3b95df8ee284c662e1707a58c73f0c927efd4724bc5dd26356d0000be3629f759eefadbf459000642facadd6b761a0e4f44b0be7f792c
@@ -1,19 +1,19 @@
1
1
  class AudioAnalysis
2
2
  def self.find_bpm(file_path)
3
- `pip install -r lib/requirements.txt`
4
- bpm = `python3 bpm_analysis.py #{file_path}`
3
+ `pip install -r lib/python_analysis/requirements.txt`
4
+ bpm = `python3 lib/python_analysis/bpm_analysis.py #{file_path}`
5
5
  bpm.to_f
6
6
  end
7
7
 
8
8
  def self.find_key(file_path)
9
- `pip install -r lib/requirements.txt`
10
- `python3 key_analysis.py #{file_path}`
9
+ `pip install -r lib/python_analysis/requirements.txt`
10
+ `python3 lib/python_analysis/key_analysis.py #{file_path}`
11
11
  end
12
12
 
13
13
  def self.analyze(file_path)
14
- `pip install -r lib/requirements.txt`
15
- bpm = `python3 bpm_analysis.py #{file_path}`
16
- key =`python3 key_analysis.py #{file_path}`
14
+ `pip install -r lib/python_analysis/requirements.txt`
15
+ bpm = `python3 lib/python_analysis/bpm_analysis.py #{file_path}`
16
+ key =`python3 lib/python_analysis/key_analysis.py #{file_path}`
17
17
  { bpm: bpm, key: key }
18
18
  end
19
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: audio_analysis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - 'Indigo Tech Tutorials '
@@ -17,9 +17,6 @@ extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
19
  - lib/audio_analysis.rb
20
- - lib/bpm_analysis.py
21
- - lib/key_analysis.py
22
- - lib/requirements.txt
23
20
  homepage: https://rubygems.org/gems/audio_analysis
24
21
  licenses:
25
22
  - MIT
data/lib/bpm_analysis.py DELETED
@@ -1,14 +0,0 @@
1
- import librosa
2
- import sys
3
-
4
- if len(sys.argv) != 2:
5
- print("You have to pass in a file path `python3 analysis.py path_to_file.mp3`")
6
- sys.exit(1)
7
-
8
- audio_file = sys.argv[1]
9
- y, sr = librosa.load(audio_file)
10
-
11
- # Estimate tempo (BPM)
12
- tempo, _ = librosa.beat.beat_track(y=y, sr=sr)
13
-
14
- print(tempo, end='')
data/lib/key_analysis.py DELETED
@@ -1,27 +0,0 @@
1
- import librosa
2
- import numpy as np
3
- import sys
4
-
5
- if len(sys.argv) != 2:
6
- print("You have to pass in a file path `python3 analysis.py path_to_file.mp3`")
7
- sys.exit(1)
8
-
9
- audio_file = sys.argv[1]
10
-
11
- y, sr = librosa.load(audio_file)
12
-
13
- # Compute the Chroma Short-Time Fourier Transform (chroma_stft)
14
- chromagram = librosa.feature.chroma_stft(y=y, sr=sr)
15
-
16
- # Calculate the mean chroma feature across time
17
- mean_chroma = np.mean(chromagram, axis=1)
18
-
19
- # Define the mapping of chroma features to keys
20
- chroma_to_key = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']
21
-
22
- # Find the key by selecting the maximum chroma feature
23
- estimated_key_index = np.argmax(mean_chroma)
24
- estimated_key = chroma_to_key[estimated_key_index]
25
-
26
- # Print the detected key
27
- print(estimated_key, end='')
data/lib/requirements.txt DELETED
@@ -1 +0,0 @@
1
- librosa==0.10.1