nara_wpe.tf_wpe module¶

tf_wpe.
batched_block_wpe_step
(Y, inverse_power, num_frames, taps=10, delay=3, mode='inv', block_length_in_seconds=2.0, forgetting_factor=0.7, fft_shift=256, sampling_rate=16000)[source]¶ Batched single WPE step. More suited for backpropagation.
Parameters:  Y (tf.Tensor) – Complex valued STFT signal with shape (B, F, D, T)
 inverse_power (tf.Tensor) – Power signal with shape (B, F, T)
 num_frames (tf.Tensor) – Number of frames for each signal in the batch
 taps (int, optional) – Filter order
 delay (int, optional) – Delay as a guard interval, such that X does not become zero.
 mode (str, optional) – Specifies how R^1@r is calculate: “inv” calculates the inverse of R directly and then uses matmul “solve” solves Rx=r for x
 block_length_in_seconds (float, optional) – Length of each block in seconds
 forgetting_factor (float, optional) – Forgetting factor for the signal statistics between the blocks
 fft_shift (int, optional) – Shift used for the STFT.
 sampling_rate (int, optional) – Sampling rate of the observed signal.
Returns: Dereverberated signal of shape B, (F, D, T)

tf_wpe.
batched_recursive_wpe
(Y, power_estimate, alpha, num_frames, taps=10, delay=2, only_use_final_filters=False)[source]¶ Batched single WPE step. More suited for backpropagation.
Parameters:  Y (tf.Tensor) – Observed signal of shape (B, T, F, D)
 power_estimate (tf.Tensor) – Estimate for the clean signal PSD of shape (B, T, F)
 alpha (float) – Smoothing factor for the recursion
 num_frames (tf.Tensor) – Number of frames for each signal in the batch
 K (int, optional) – Number of filter taps.
 delay (int, optional) – Delay
 only_use_final_filters (bool, optional) – Applies only the final estimated filter coefficients to the whole signal. This is for debugging purposes only and makes this method a offline one.
Returns: Dereverberated signal of shape (B, T, F, D)

tf_wpe.
batched_wpe
(Y, num_frames, taps=10, delay=3, iterations=3, mode='inv')[source]¶ Batched version of iterative WPE.
Parameters:  Y (tf.Tensor) – Observed signal with shape (B, F, D, T)
 num_frames (tf.Tensor) – Number of frames for each signal in the batch
 taps (int, optional) – Defaults to 10. Number of filter taps.
 delay (int, optional) – Defaults to 3.
 iterations (int, optional) – Defaults to 3.
 mode (str, optional) – Specifies how R^1@r is calculate: “inv” calculates the inverse of R directly and then uses matmul “solve” solves Rx=r for x
Returns: Dereverberated signal of shape (B, F, D, T).
Return type: tf.Tensor

tf_wpe.
batched_wpe_step
(Y, inverse_power, num_frames, taps=10, delay=3, mode='inv', Y_stats=None)[source]¶ Batched single WPE step. More suited for backpropagation.
Parameters:  Y (tf.Tensor) – Complex valued STFT signal with shape (B, F, D, T)
 inverse_power (tf.Tensor) – Power signal with shape (B, F, T)
 num_frames (tf.Tensor) – Number of frames for each signal in the batch
 taps (int, optional) – Filter order
 delay (int, optional) – Delay as a guard interval, such that X does not become zero.
 mode (str, optional) – Specifies how R^1@r is calculate: “inv” calculates the inverse of R directly and then uses matmul “solve” solves Rx=r for x
 Y_stats (tf.Tensor or None, optional) – Complex valued STFT signal with shape (F, D, T) use to calculate the signal statistics (i.e. correlation matrix/vector). If None, Y is used. Otherwise it’s usually a segment of Y
Returns: Dereverberated signal of shape B, (F, D, T)

tf_wpe.
block_wpe_step
(Y, inverse_power, taps=10, delay=3, mode='inv', block_length_in_seconds=2.0, forgetting_factor=0.7, fft_shift=256, sampling_rate=16000)[source]¶ Applies wpe in a blockwise fashion.
Parameters:  Y (tf.Tensor) – Complex valued STFT signal with shape (F, D, T)
 inverse_power (tf.Tensor) – Power signal with shape (F, T)
 taps (int, optional) – Defaults to 10.
 delay (int, optional) – Defaults to 3.
 mode (str, optional) – Specifies how R^1@r is calculate: “inv” calculates the inverse of R directly and then uses matmul “solve” solves Rx=r for x
 block_length_in_seconds (float, optional) – Length of each block in seconds
 forgetting_factor (float, optional) – Forgetting factor for the signal statistics between the blocks
 fft_shift (int, optional) – Shift used for the STFT.
 sampling_rate (int, optional) – Sampling rate of the observed signal.

tf_wpe.
get_correlations
(Y, inverse_power, taps, delay)[source]¶ Calculates weighted correlations of a window of length taps
Parameters:  Y (tf.Ttensor) – Complexvalued STFT signal with shape (F, D, T)
 inverse_power (tf.Tensor) – Weighting factor with shape (F, T)
 taps (int) – Lenghts of correlation window
 delay (int) – Delay for the weighting factor
Returns: Correlation matrix of shape (F, taps*D, taps*D) tf.Tensor: Correlation vector of shape (F, taps*D)
Return type: tf.Tensor

tf_wpe.
get_correlations_for_single_frequency
(Y, inverse_power, taps, delay)[source]¶ Calculates weighted correlations of a window of length taps for one freq.
Parameters:  Y (tf.Ttensor) – Complexvalued STFT signal with shape (D, T)
 inverse_power (tf.Tensor) – Weighting factor with shape (T)
 K (int) – Lenghts of correlation window
 delay (int) – Delay for the weighting factor
Returns: Correlation matrix of shape (taps*D, taps*D) tf.Tensor: Correlation vector of shape (D, taps*D)
Return type: tf.Tensor

tf_wpe.
get_filter_matrix_conj
(Y, correlation_matrix, correlation_vector, taps, delay, mode='solve')[source]¶ Calculate (conjugate) filter matrix based on correlations for one freq.
Parameters:  Y (tf.Tensor) – Complexvalued STFT signal of shape (D, T)
 correlation_matrix (tf.Tensor) – Correlation matrix (taps*D, taps*D)
 correlation_vector (tf.Tensor) – Correlation vector (D, taps*D)
 K (int) – Number of filter taps
 delay (int) – Delay
 mode (str, optional) – Specifies how R^1@r is calculate: “inv” calculates the inverse of R directly and then uses matmul “solve” solves Rx=r for x
Raises: ValueError
– Unknown mode specifiedReturns: (Conjugate) filter Matrix
Return type: tf.Tensor

tf_wpe.
get_power
(signal, axis=2)[source]¶ Calculates power for signal
Parameters:  signal (tf.Tensor) – Single frequency signal with shape (D, T) or (F, D, T).
 axis – reduce_mean axis
Returns: Power with shape (T,) or (F, T)
Return type: tf.Tensor

tf_wpe.
get_power_inverse
(signal)[source]¶ Calculates inverse power for signal
Parameters:  signal (tf.Tensor) – Single frequency signal with shape (D, T).
 psd_context – context for power estimation
Returns: Inverse power with shape (T,)
Return type: tf.Tensor

tf_wpe.
get_power_online
(signal)[source]¶ Calculates power for signal
Parameters: signal (tf.Tensor) – Signal with shape (F, D, T). Returns: Power with shape (F,) Return type: tf.Tensor

tf_wpe.
online_wpe_step
(input_buffer, power_estimate, inv_cov, filter_taps, alpha, taps, delay)[source]¶ One step of online dereverberation
Parameters:  input_buffer (tf.Tensor) – Buffer of shape (taps+delay+1, F, D)
 power_estimate (tf.Tensor) – Estimate for the current PSD
 inv_cov (tf.Tensor) – Current estimate of R^1
 filter_taps (tf.Tensor) – Current estimate of filter taps (F, taps*D, taps)
 alpha (float) – Smoothing factor
 taps (int) – Number of filter taps
 delay (int) – Delay in frames
Returns: Dereverberated frame of shape (F, D) tf.Tensor: Updated estimate of R^1 tf.Tensor: Updated estimate of the filter taps
Return type: tf.Tensor

tf_wpe.
perform_filter_operation
(Y, filter_matrix_conj, taps, delay)[source]¶ >>> D, T, taps, delay = 1, 10, 2, 1 >>> tf.enable_eager_execution() >>> Y = tf.ones([D, T]) >>> filter_matrix_conj = tf.ones([taps, D, D]) >>> X = perform_filter_operation_v2(Y, filter_matrix_conj, taps, delay) >>> X.shape TensorShape([Dimension(1), Dimension(10)]) >>> X.numpy() array([[ 1., 0., 1., 1., 1., 1., 1., 1., 1., 1.]], dtype=float32)

tf_wpe.
recursive_wpe
(Y, power_estimate, alpha, taps=10, delay=2, only_use_final_filters=False)[source]¶ Applies WPE in a framewise recursive fashion.
Parameters:  Y (tf.Tensor) – Observed signal of shape (T, F, D)
 power_estimate (tf.Tensor) – Estimate for the clean signal PSD of shape (T, F)
 alpha (float) – Smoothing factor for the recursion
 taps (int, optional) – Number of filter taps.
 delay (int, optional) – Delay
 only_use_final_filters (bool, optional) – Applies only the final estimated filter coefficients to the whole signal. This is for debugging purposes only and makes this method a offline one.
Returns: Enhanced signal
Return type: tf.Tensor

tf_wpe.
single_frequency_wpe
(Y, taps=10, delay=3, iterations=3, mode='inv')[source]¶ WPE for a single frequency.
Parameters:  Y – Complex valued STFT signal with shape (D, T)
 taps – Number of filter taps
 delay – Delay as a guard interval, such that X does not become zero.
 iterations –
 mode (str, optional) – Specifies how R^1@r is calculate: “inv” calculates the inverse of R directly and then uses matmul “solve” solves Rx=r for x
Returns:

tf_wpe.
wpe
(Y, taps=10, delay=3, iterations=3, mode='inv')[source]¶ WPE for all frequencies at once. Use this for regular processing.
Parameters:  Y (tf.Tensor) – Observed signal with shape (F, D, T)
 num_frames (tf.Tensor) – Number of frames for each signal in the batch
 taps (int, optional) – Defaults to 10. Number of filter taps.
 delay (int, optional) – Defaults to 3.
 iterations (int, optional) – Defaults to 3.
 mode (str, optional) – Specifies how R^1@r is calculated: “inv” calculates the inverse of R directly and then uses matmul “solve” solves Rx=r for x
Returns: Dereverberated signal tf.Tensor: Latest estimation of the clean speech PSD
Return type: tf.Tensor

tf_wpe.
wpe_step
(Y, inverse_power, taps=10, delay=3, mode='inv', Y_stats=None)[source]¶ Single step of ‘wpe’. More suited for backpropagation.
Parameters:  Y (tf.Tensor) – Complex valued STFT signal with shape (F, D, T)
 inverse_power (tf.Tensor) – Power signal with shape (F, T)
 taps (int, optional) – Filter order
 delay (int, optional) – Delay as a guard interval, such that X does not become zero.
 mode (str, optional) – Specifies how R^1@r is calculate: “inv” calculates the inverse of R directly and then uses matmul “solve” solves Rx=r for x
 Y_stats (tf.Tensor or None, optional) – Complex valued STFT signal with shape (F, D, T) use to calculate the signal statistics (i.e. correlation matrix/vector). If None, Y is used. Otherwise it’s usually a segment of Y
Returns: Dereverberated signal of shape (F, D, T)