Don't save empty recordings

Hi,

Is there a way i can know after the RECORD function is completed if the recording is silent or is not human talk something like AMD?

Or can i check the file with a linux command?

You can check the file offline, but there probably won’t be a standard Linux command.

Can i do it with sox?

The file size of an empty WAV file is 44 bytes – the size of the WAV header.

I use this in a shell script to detect voicemail recordings I’m not interested in:

	threshold=40000
	max=$(sudo sox ${file} --null stat 2>&1 | awk '/Maximum amplitude:/ {printf "%d\n", $3 * 1000000}')
	if	[ ${threshold} -gt ${max} ]
		then
		.
		.
		.

What are you looking for in your voicemail files?

Basically anything above silence and background noise.

What is Maximum amplitude?

Loosely ‘volume’ – how loud.

What is the level of human talk? i need talk that is 2 seconds too

Did you test it and came to the conclusion that less than 4000 is not human?

The 40k threshold seems to work for me.

1 Like

Thanks i will test it

The number of seconds or the number of samples output by sox may also be of interest.

I’ve seen other posts mention RMS what is that?

Also whey do you use Maximum and not Midline?

I won’t pretend I understand it :slight_smile: Root Mean Square

Max seemed to give me the result I was interested in. I’m not an expert, just a user.

You might be able to create a file with silence stripped using sox and see if that had a zero payload length.

The file size of an empty WAV file is 44 bytes – the size of the WAV header.

I use this in a shell script to detect voicemail recordings I’m not interested in:

	threshold=40000
	max=$(sudo sox ${file} --null stat 2>&1 | awk '/Maximum amplitude:/ {printf "%d\n", $3 * 1000000}')
	if	[ ${threshold} -gt ${max} ]
		then
		.
		.
		.

How can i execute this from fastagi?
I tried Eexc("Set","amp=${SHELL(sox filename.wav -n stat 2>&1 | awk '/Maximum amplitude:/ {printf \"\" % d\\n\"\", $3 * 1000000}')}") and it didn’t work it set the variable with the text

In no particular order…

  1. If your fastagi host is not your Asterisk host, you can’t unless you have your Asterisk recording directory mounted on the fastagi host.
  2. Does ‘agi set debug on’ yield any clues?
  3. Is ‘filename.wav’ in the AGI’s PWD or do you need to specify an absolute path?
  4. If you execute the command from a shell do you get an expected response? Does trimming ‘| awk…’ yield any clues?
  5. Does the user executing Asterisk have permissions to filename.wav?
  6. Is escaping quotes getting in your way? I did this in a shell script where it isn’t an issue.
  7. Did you try ‘get variable’ or ‘get full variable?’