'Spawns a thread to repeatedly record phrases from ``source`` (an ``AudioSource`` instance) into an ``AudioData`` instance and call ``callback`` with that ``AudioData`` instance as soon as each phrase are detected.
Returns a function object that, when called, requests that the background listener thread stop, and waits until it does before returning. The background thread is a daemon and will not stop the program from exiting if there are no other non-daemon threads.
Phrase recognition uses the exact same mechanism as ``recognizer_instance.listen(source)``. The ``phrase_time_limit`` parameter works in the same way as the ``phrase_time_limit`` parameter for ``recognizer_instance.listen(source)``, as well.
The ``callback`` parameter is a function that should accept two parameters - the ``recognizer_instance``, and an ``AudioData`` instance representing the captured audio. Note that ``callback`` function will be called from a non-main thread.'

def listen_in_background(self, source, callback, phrase_time_limit=None):

    assert isinstance(source, AudioSource), 'Source    must    be    an    audio    source'
    running = [True]
    def threaded_listen():
        with source as s:
            while running[0]:
                try:
                    audio = self.listen(s, 1, phrase_time_limit)
                except WaitTimeoutError:
                    pass
                else:
                    if running[0]:
                        callback(self, audio)
    def stopper():
        running[0] = False
        listener_thread.join()
    listener_thread = threading.Thread(target=threaded_listen)
    listener_thread.daemon = True
    listener_thread.start()
    return stopper
