I am trying to write a code for my thesis to deconvolve a recording with an impulse response so that I can achieve the original audio signal. I have written a simple code so that I can implement this but it is not working. Here is the code:
import numpy as np
import matplotlib.pyplot as plt
import scipy.signal
import scipy.io.wavfile as wavfile
IR_PATH = "case11_ir.wav"
AUDIO_EXCERPT_PATH = "case1_gtr.wav"
#%% Loading the IRs
fs, case_ir_sig = wavfile.read(IR_PATH)
case_ir_sig = case_ir_sig[case_ir_sig != 0]
rec_fs, rec_sig = wavfile.read(AUDIO_EXCERPT_PATH)
assert(fs == rec_fs)
dry_sig, r = scipy.signal.deconvolve(rec_sig, case_ir_sig)
dry_sig = dry_sig / np.max(np.abs(dry_sig))
wavfile.write("case11.wav", fs, dry_sig)
The problem seems to be at the deconvolution line, whereas I cannot see the dry_sig
in the variable explorer. I have used float 32 format for all wav files. And here are the wav files. case1_gtr
is the convolved audio, case11_ir
is the impulse response, and case_original
is the original recording that I am trying to achieve (at least something similar to it) as the product of deconvolution.
Any suggestions?