4

I'm looking for any piece of software that would record a sound and play it back after certain delay set by user (e.g. 10 seconds). In other words, I would like to constantly listen - on my headphones - to what's going on near the microphone, but with a certain delay.

Software requirements:

  • any price
  • any operating system (Windows / Linux / OS X)
  • any user interface (command-line / graphical)
  • optional feature for saving audio
  • do you will need a solution ? below suggestions are not automated regarding auto playback after defined delay period ... actual solution could involve a circular memory buffer which is constantly populated by mic and rendered to audio from say an OpenAL server very doable with some effort – Scott Stensland Aug 30 '16 at 21:26
2

VLC media player

  • Free and open-source
  • Windows, macOS and Linux are supported
  • Graphical, there might be a CLI way of doing the steps listed below, though
  • I couldn't figure out how to play the stream while saving it to a file. You might want to ask this as a separate question on SU or in the VLC forums.

Steps:

  1. In the menu click 'Media', then 'Open Capture Device': Screenshot of the Media menu

    • Select 'None' as your video device name and optionally set your audio device name to a specific audio device (e.g. if you have multiple ones).

    • Activate the 'Show more options' checkbox at the bottom of the dialog.

    • Set the caching time to your desired delay.

    • Leave the other options untouched and click 'Play'.

    Capture Device dialog with the settings as described in the text

1

You can do this in Python. Here is an example using sounddevice.

Below example records audio from microphone for #seconds as per variable duration which you can modify as per your requirements.

Same contents are played back using standard audio output (speakers).
This code can be scripted and played in a loop.
More on this over here

Working Code

import sounddevice as sd
import numpy as np
import scipy.io.wavfile as wav

fs=44100
duration = 10  # seconds
myrecording = sd.rec(duration * fs, samplerate=fs, channels=2, dtype='float64')
print "Recording Audio for %s seconds" %(duration)
sd.wait()
print "Audio recording complete , Playing recorded Audio"
sd.play(myrecording, fs)
sd.wait()
print "Play Audio Complete"

Output

Python 2.7.9 (default, Dec 10 2014, 12:24:55) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>> 
Recording Audio for 10 seconds
Audio recording complete , Playing recorded Audio
Play Audio Complete
>>> 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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