Message Boards Message Boards

1 Reply
1 Total Likes
View groups...
Share this post:

Controlling audio recording in real time

Posted 12 years ago
I was just reading Christopher Purcell's post about system-prompted audio recording in Mathematica and was wondering about an extended application. In the fourth reply Christopher presents a script made from Szabolcs Horvat's suggestions. I was wondering if there would be a way to control the recording process in real time, such as start recording, wait two seconds, and stop recording when audio level drops below speech threshold (i.e. when the person stops talking.) This would be of particular use in speech recognition, which I have already shown an interest in.
POSTED BY: Jesse Friedman
Here is a hint that what you are suggesting will be possible. This is a semi-real time audio level meter
that on my iMac OSX 10.9.5 system with Mathematica Version 9,  shows rapid responses to audio inputs to the system microphone. I don't know if my attempt to convert the 
data to a decibel form is needed. Am guessing here on the meaning of the data returned by record[9] as being the Absolute value of the last measurement.

FrontEndExecute[ FrontEnd`RecordSound[4]];
FrontEndExecute[ FrontEnd`RecordSound[7]];
FrontEndExecute[ FrontEnd`RecordSound[8]];
record[m_, n_: 0] := FrontEndExecute[FrontEnd`RecordSound[m, n]];
FrontEnd`RecordSound[1, 0, 0]]; (* start recording *)
ThermometerGauge[20 Log[10, record[9]], {-20, 0}],
UpdateInterval -> 0.01]

For your application, you would continuously read record[9] and when it drops below a threshold, you would stop recording with record[2] and then return record[3].
You might fancy this up by applying a low pass filter to the real time signal, before thresholding, so the system is not too responsive.

Edit, 15 October 2014. I have added some resets to make this more reliable. It is ok running on Mathematica 9, but not on Version 10.
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract