처음 게시 할 때 이것이 어떻게되는지보십시오.파이썬을 사용하여 wav 파일에 무성 프레임 추가
파이썬에서 wav 파일의 시작 부분에 두 번째 침묵을 추가하는 스크립트를 작성하려고했지만 지금까지는 실패했습니다.
내가하려는 것은 웨이브 헤더에서 읽은 다음 웨이브 모듈을 사용하여 처음에 \ 0을 추가하는 것입니다.하지만 그다지 잘 작동하지 않습니다. 여기에 내가 오디오 아이폰에 입력과 동일하지 않습니다으로 침묵을 추가하려고하면 오류가 생긴다 위의 코드를 사용하여 http://andrewslotnick.com/posts/audio-delay-with-python.html
import wave
from audioop import add
def input_wave(filename,frames=10000000): #10000000 is an arbitrary large number of frames
wave_file = wave.open(filename,'rb')
params=wave_file.getparams()
audio=wave_file.readframes(frames)
wave_file.close()
return params, audio
#output to file so we can use ipython notebook's Audio widget
def output_wave(audio, params, stem, suffix):
#dynamically format the filename by passing in data
filename=stem.replace('.wav','_{}.wav'.format(suffix))
wave_file = wave.open(filename,'wb')
wave_file.setparams(params)
wave_file.writeframes(audio)
# delay the audio
def delay(audio_bytes,params,offset_ms):
"""version 1: delay after 'offset_ms' milliseconds"""
#calculate the number of bytes which corresponds to the offset in milliseconds
offset= params[0]*offset_ms*int(params[2]/1000)
#create some silence
beginning= b'\0'
#remove space from the end
end= audio_bytes
return add(audio_bytes, beginning+end, params[0])
audio_params, aduio_bytes = input_wave(<audio_file>)
output_wave(delay(aduio_bytes,audio_params,10000), audio_params, <audio_file>, <audio_file_suffics>)
여기에서 기반 코드입니다.
저는 오디오 프로세싱에 새로운 것이므로 지금은 무엇이든 시도하고 있습니다.
어떤 조언이나 아이디어에 접근하는 것이 좋습니다 :). 또한 내가 파이썬에게 2.7.5
많은 감사를 사용하고
.
쿨 감사합니다. 기분 좋게 움직여주세요. – Madmax