2017-10-17 1 views
0
내가 어떻게

에 파이썬에서 디코더/: Encodeer 및 WAV에서 빈

  • 내 오디오 파일을 읽을 이진 파일에
  • 상점,

누군가가 나에게 줄 수 예 인코더를 구현하기 및 디코더 파이썬?

+0

는 "바이너리 파일"로 무슨 뜻입니까? 그러한 파일은 어떻게 생겼습니까? – Chickenmarkus

+0

*** 빈 함 –

답변

1

scipy.wave를 사용하여 wav 파일을 읽고 쓸 수 있습니다. 데이터를 저장하려면 numpy를 사용할 수 있습니다.

오디오 파일을 효과적으로 샘플 당 16 비트 인코딩되어있는 경우, 당신은 아무것도 할 필요가 없습니다이이 같은 의지해야합니다

from scipy.io.wavfile import read as wavread 
from scipy.io.wavfile import write as wavwrite 
import numpy as np 

sr, sig = wavread(audioFileName) #read the audio file (samplig rate, signal) 
sig_int8 = np.uint8(sig) # cast the data in uint8 
np.savez(out_file, sig = sig_int8) # store the data 

npzfile = np.load(out_file + '.npz') #load the data 
sig = npzfile['sig'] 

wavwrite(audioFileName2, sr, sig) #write data in wav file 
+0

파일을 8 비트 샘플로 오디오 파일을 양자화해야 할 경우 프로그램에서 무엇을 변경해야합니까? –

+0

scipy write에는 rate 옵션이 있습니다. 여기를 참조하십시오 : https://docs.scipy.org/doc/scipy-0.18.1/reference/generated/scipy.io.wavfile.write.html – PatriceG

+0

나는 다음과 같이 smt를 작성했습니다 : wavwrite (파일 이름, sr, 'uint8') anf : 'str'객체에 'dtype'속성이 없습니다. –