File size: 672 Bytes
d0d3136
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python
# coding: utf-8

# In[ ]:


import os
import pandas as pd
from pandas.core.frame import DataFrame

from tqdm import tqdm, tqdm_pandas
tqdm.pandas()

import librosa
import librosa.display

import matplotlib.pyplot as plt

def Data_Generator():
    list_test = []
    for j in os.listdir('./test/'):
        list_test.append('./test/'+j)
    fname = list_test[0]
    return fname

def Audio(fname,SAMPLE_RATE):
    # 提取時域音頻資料
    y, sr = librosa.load(fname, sr=SAMPLE_RATE)    
    # plot a waveform
    plt.figure()  
    librosa.display.waveplot(y, sr)  
    plt.title('Waveplot of unknow frog sound')  
    plt.show()
    return y,sr