반응형
    
    
    
  
| 
 1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
 | 
 import librosa 
import soundfile 
import os 
def down_sample(source_path,dest_path): 
    extlist = ['.wav', '.pcm'] 
    for (path, dir, files) in os.walk(source_path): 
        for filename in files: 
            ext = os.path.splitext(filename)[-1] 
            if ext in extlist: 
                wav_source_path = source_path + os.sep + filename 
                wav_dest_path = dest_path + os.sep + filename 
                y,sr = librosa.load(wav_source_path, sr=44100) 
                resample = librosa.resample(y,sr,22050) 
                soundfile.write(wav_dest_path,resample,22050) 
if __name__ == '__main__': 
    source_path = '<Sound File Path for Load>' 
    dest_path = '<Sound File Path to Save' 
    down_sample(source_path, dest_path) 
 | 
cs | 
반응형
    
    
    
  'Python' 카테고리의 다른 글
| [Python] Garbage Collection 파이썬 가비지 콜렉션 (0) | 2023.02.06 | 
|---|---|
| [Python] 파이썬에서 YAML(야믈) 사용하기 (0) | 2022.12.13 | 
| [Flask] Python으로 REST API 만들기 (0) | 2022.08.18 | 
| [Pandas] 데이터프레임 날짜/시간을 날짜로 변환하는 방법 (0) | 2022.08.16 | 
| [Error] Can't get attribute '_unpickle_block' on <module 'pandas._libs.internals' 해결 방법 (0) | 2022.05.25 | 
										
									
										
									
댓글