0
我有一個.wav音頻文件,我正在將音頻轉換爲文本。我需要減少/消除噪音以獲得更準確的結果。如何從python中的.wav音頻文件中刪除/減少噪聲
請讓我知道如何去了解它
import wave
import sys
import binascii
ip = wave.open('C:\\Users\\anagha\\Documents\\Python Scripts\\a1.wav', 'r')
op = wave.open('C:\\Users\\anagha\\Documents\\Python Scripts\\r_1.wav', 'w')
op.setparams(ip.getparams())
for i in range(ip.getnframes()):
iframes = ip.readframes(1)
amp = int(binascii.hexlify(iframes))
if amp > 32767:
amp = 65535 - int(binascii.hexlify(iframes))#-ve
print(amp)
else:
amp = int(binascii.hexlify(iframes))#+ve
print(amp)
if amp < 2000:
#make it zero
final_frame = '\x00\x00'
else:
#Keep the frame
final_frame = iframe
op.writeframes(final_frame)
op.close()
ip.close()
收到錯誤:
ValueError: invalid literal for int() with base 10: b'ffff'