yfyangd commited on
Commit
d0d3136
1 Parent(s): c2f9453

Upload DataGenerator.py

Browse files
Files changed (1) hide show
  1. DataGenerator.py +34 -0
DataGenerator.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ # coding: utf-8
3
+
4
+ # In[ ]:
5
+
6
+
7
+ import os
8
+ import pandas as pd
9
+ from pandas.core.frame import DataFrame
10
+
11
+ from tqdm import tqdm, tqdm_pandas
12
+ tqdm.pandas()
13
+
14
+ import librosa
15
+ import librosa.display
16
+
17
+ import matplotlib.pyplot as plt
18
+
19
+ def Data_Generator():
20
+ list_test = []
21
+ for j in os.listdir('./test/'):
22
+ list_test.append('./test/'+j)
23
+ fname = list_test[0]
24
+ return fname
25
+
26
+ def Audio(fname,SAMPLE_RATE):
27
+ # 提取時域音頻資料
28
+ y, sr = librosa.load(fname, sr=SAMPLE_RATE)
29
+ # plot a waveform
30
+ plt.figure()
31
+ librosa.display.waveplot(y, sr)
32
+ plt.title('Waveplot of unknow frog sound')
33
+ plt.show()
34
+ return y,sr