This repository contains a MATLAB script (EchoCanceller.m) for non-realtime audio processing, focusing on echo cancellation for dual-channel audio files. The script processes WAV files with near-end microphone and far-end speaker signals, applying frequency-domain NLMS-based echo cancellation to produce a clean output with reduced echo.
- Echo Cancellation: Implements frequency-domain NLMS-based echo cancellation with adaptive spectral smoothing to effectively suppress echo in dual-channel audio.
- Dual-Channel Support: Processes dual-channel WAV files (near-end microphone and far-end speaker signals).
- Dynamic Frequency Range: Adjusts echo frequency range (100 Hz to 4000 Hz) to cover low-frequency echo and speech frequencies.
- Sampling Rate Support: Supports 8 kHz and 16 kHz sampling rates with adjustable parameters (
cohRange,mufb). - Post-Processing: Includes residual echo suppression and dual-channel gain normalization to maintain energy levels.
- Visualization: Provides detailed plots for analysis, including time-domain waveforms, spectrograms, and energy (dB) plots for both input and output signals.
- Energy Compensation: Ensures energy retention through dual-channel gain normalization, preserving natural speech levels.
- MATLAB: This script requires MATLAB (tested with R2020a and later versions).
- Audio File: A dual-channel WAV file with the following specifications:
- Channel 1: Near-end microphone signal (with echo).
- Channel 2: Far-end speaker signal (reference for echo cancellation).
- Supported sampling rates: 8 kHz or 16 kHz.
- Clone the repository to your local machine:
git clone https://github.com/MetaAcoustix/EchoCanceller.git
- Navigate to the repository directory:
cd EchoCanceller - Ensure MATLAB is installed and added to your system path.
-
Prepare Input File:
- Place your dual-channel WAV file (e.g.,
original_signal.wav) in the repository directory. - Ensure the file meets the requirements (dual-channel, 8 kHz or 16 kHz sampling rate).
- Place your dual-channel WAV file (e.g.,
-
Run the Script:
- Open MATLAB and navigate to the repository directory.
- Open the script
EchoCanceller.m. - Update the
filenamevariable in the script to match your input file:filename = 'original_signal.wav';
- Run the script:
run EchoCanceller.m
-
Output:
- The processed audio will be saved as
mout_core_original_signal.wavin the same directory. - Two figures will be displayed:
- Input Signal Acoustic Plot: Time-domain waveforms, spectrogram, and energy plot for the input near-end signal.
- Output Signal Acoustic Plot: Time-domain waveforms, spectrogram, and energy plot for the processed near-end signal.
- The processed audio will be saved as
-
Analyze Results:
- Check the output WAV file for echo suppression and speech clarity.
- Review the spectrogram to confirm echo reduction.
- Inspect the energy plot to ensure energy levels are preserved.
- File:
original_signal.wav - Format: Dual-channel WAV, 16 kHz sampling rate
- Channel 1: Near-end microphone signal (with echo)
- Channel 2: Far-end speaker signal
run EchoCanceller.m- File:
mout_core_original_signal.wav - Format: Dual-channel WAV, 16 kHz sampling rate
- Channel 1: Processed near-end signal (echo suppressed)
- Channel 2: Original far-end signal (unchanged)
- Input Spectrogram: Shows echo and noise in the near-end signal.
- Output Spectrogram: Shows reduced echo with preserved speech.
To test the script:
- Use a dual-channel WAV file with known echo (e.g., recorded during a speakerphone call).
- Run the script as described in the Usage section.
- Verify the output:
- Listen to
mout_core_original_signal.wavto confirm echo reduction. - Check the spectrogram for echo suppression (reduced energy in echo frequency bands).
- Ensure speech clarity is maintained and no significant distortion is introduced.
- Listen to
Contributions are welcome! To contribute:
- Fork the repository.
- Create a new branch for your feature or bug fix:
git checkout -b feature/your-feature-name
- Make your changes and test thoroughly.
- Commit your changes with a descriptive message:
git commit -m "Add feature: your feature description" - Push to your fork:
git push origin feature/your-feature-name
- Open a Pull Request with a detailed description of your changes.
- Add support for additional sampling rates (e.g., 44.1 kHz).
- Integrate noise suppression for specific frequencies (e.g., 440 Hz).
- Enhance distortion handling with low-pass filtering.
- Add non-linear processing (NLP) for residual echo suppression.
This project is licensed under the MIT License. See the LICENSE file for details.