Browse Source

dance test code

zhuo 4 years ago
parent
commit
4f6908bd05
1 changed files with 8 additions and 6 deletions
  1. 8 6
      src/robot_dance/scripts/robot_dance.py

+ 8 - 6
src/robot_dance/scripts/robot_dance.py

@@ -3,7 +3,7 @@
 '''
 Author: adam_zhuo
 Date: 2021-01-08 15:39:22
-LastEditTime: 2021-01-12 20:02:11
+LastEditTime: 2021-01-18 17:50:27
 LastEditors: Please set LastEditors
 Description: In User Settings Edit
 FilePath: /blackTornadoRobot/src/robot_dance/scripts/robot_dance.py
@@ -21,11 +21,13 @@ class Dance:
     
     def plot(self):
         y, sr = librosa.load(self.path, sr=None)
-        librosa.samples_to_time(np.arange(0, 10000, sr))
-        print("time is ",sr)
-        # onset_env = librosa.onset.onset_strength(y=y, sr=sr,
-        #                                      hop_length=256,
-        #                                      aggregate=np.median)
+        print("sr is",sr)
+        # librosa.samples_to_time(np.arange(0, 10000, sr))
+        print("time is ",len(y)/sr)
+        o_env = librosa.onset.onset_strength(y=y, sr=sr,
+                                             hop_length=44100,
+                                             aggregate=np.median)
+        print("o_env is ",o_env)
         # print("sr is",sr)
         # print("onset shape is",np.shape(onset_env))
         # dby = librosa.amplitude_to_db(y, ref=1.0)