Skip to content

Commit d8dbe85

Browse files
committed
Avoid singular matrix in linear system solver for LPC
1 parent 46fb70a commit d8dbe85

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

speechbrain/processing/voice_analysis.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,11 @@ def inverse_filter(frames, lpc_order=13):
283283
autocorrelation = autocorrelation.view(batch * frame_count, -1)
284284
reshaped_frames = frames.view(batch * frame_count, -1)
285285

286+
# An autocorrelation of all 0's -- which can happen in padding -- leads to
287+
# an error with the linear system solver, as the matrix is singular
288+
# We fix this by ensuring the zero-lag correlation is always 1
289+
autocorrelation[:, lpc_order] = 1.0
290+
286291
# Construct Toeplitz matrices (one per frame)
287292
# This is [[p0, p1, p2...], [p1, p0, p1...], [p2, p1, p0...] ...]
288293
# Our sliding window should go from the end to the front, so flip

0 commit comments

Comments
 (0)