First time asking a question on SE; Google and old SE questions have always gotten me by before. :) I think this is the right place to ask.

Background: I'm working with linux (ultimately an RPi, to be specific, but testing on Mint 18) planning to record audio from a mic and simultaneously output text-to-speech audio to a user. I'm working under the assumption that the output is going to play over a speaker near the mic. I haven't set up the hardware yet, as I want to make sure this is a feasible project first.

Problem: I'm trying to figure out how to filter out the TTS audio I'm producing from the mic audio that I'm recording.

I can't even figure out the search terms to use on Google, though it seems like this has to have been covered before.

So my questions are 1) what search terms can I use to find information on this, and 2) are there any preexisting linux tools that can do this?

Thanks for any and all pointers. First time in years that I haven't found the solution to my probs on my own.

EDIT: I should have clarified, this is something I'm hoping to do via a script on the command line, maybe even live.

  • Looks like this is as close as I've come to a solution, based on further research: dsp.stackexchange.com
    – JBron
    Commented Nov 15, 2016 at 16:43

3 Answers 3


TL;DR: Headphones.

This is a monumentally complex task to accomplish with live audio but it just might be possible with the generated waveform from the Text to Speech software (By somehow reversing the phase of the waveform and adding it back to the input source at the exact, precisely correct time to cancel what's coming out of the speakers.

Timing & phasing would pose great challenges though. Things like the distance between speaker & microphone, air temperature, room design, these would all affect the results, and the processed input might cause problems with the speech recognitions software.

You can see how this concept gets daunting quickly. This is all solved by requiring the listener to wear headphones.

P.S. Even though Skype and most voice/video chat software have feedback reduction features, the results can often be subpar when more than a few people are on the call. My origination requires all conference users to wear a headset for this reason. The problem is just not usually worth the investment needed to solve it.

  • Thanks for the obvious solution. In my case, that could actually work.
    – JBron
    Commented Dec 30, 2016 at 17:57

There are methods of doing this very complex task. For example two-way communication software applications like Skype, Google Hangouts, etc. have methods of cancelling the speaker audio from the microphone signal. Suggest researching how they do it to avoid re-inventing the wheel. Don't expect that this is going to be either simple or easy. You may not even have enough processing power in a RasPi. Especially if you want to run other sophisticated software concurrently. If you think you can do this from the command line, you are dreaming.


If you are simply attempting to keep the "bleed" of the text to speech out of the mic input, why don't you just monitor out put through headphones instead of a speaker?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.