audio_analysis 0.0.3 → 0.0.5

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: 7c6ee2bf1738a0fefba9106383ac99014910171a22d0e34f86b72a201a3d3ae5
4
- data.tar.gz: e5d37d7b4215d3772ce5c46b35e3424134bcdf1f6cf59896eb0380364a7031f0
3
+ metadata.gz: 77f3e6d28dab05d54e885f1d430c3e1034ad56c1ef318ffc7fcc01584022bdd3
4
+ data.tar.gz: 24a283dcf4579c575fcb82f3b661423a476fcd9df0ff9ab5163421fb9210f517
5
5
  SHA512:
6
- metadata.gz: fce4fab5dc03e927721825c46999cb0d1e181ad4cd82086d917a69aeb577ce491bbaf4c3310d9849d8665c581059a355e3746ba3095a23b438489da233f3ec56
7
- data.tar.gz: 3494f50f35eb17713fc752760a3625d58bdb0d48a94e350a3bfbc1cc939f667da73c4b0ac45fa02f37841371d5ab7e93d4486e721fbbdb2ccdaaf6a9dcef1f11
6
+ metadata.gz: 78c530c25407cc5975649e213043cecb66e8262e1c7b86c7a8fce6a8dbb6064ed2056ac0b5ab3aade7ed9d5f70faa4417d98921b21f07c42f5b801076c7c1733
7
+ data.tar.gz: d8caae585bd56c1266fe705f3c5538386dc59db3b45d9862238f3488c244edaa1c8b7c6e83991ab6007ed80687b60afb16fe27cc2256080053c39f4190e77856
@@ -20,6 +20,6 @@ class AudioAnalysis
20
20
  private
21
21
 
22
22
  def self.gem_path
23
- Gem.datadir("audio_analysis")
23
+ Gem.loaded_specs["audio_analysis"].gem_dir
24
24
  end
25
25
  end
@@ -0,0 +1,14 @@
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='')
@@ -0,0 +1,27 @@
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='')
@@ -0,0 +1 @@
1
+ librosa==0.10.1
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.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - 'Indigo Tech Tutorials '
@@ -17,6 +17,9 @@ extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
19
  - lib/audio_analysis.rb
20
+ - lib/python_analysis/bpm_analysis.py
21
+ - lib/python_analysis/key_analysis.py
22
+ - lib/python_analysis/requirements.txt
20
23
  homepage: https://rubygems.org/gems/audio_analysis
21
24
  licenses:
22
25
  - MIT