Re: [asterisk-users] sound file length

2006-09-22 Thread Tobias Wolf
Raphael Jacquot schrieb:
 At some point in my dial plan, I need to find out the length of a sound
 file in seconds (to weed out things that are way too short)
 
 the record application doesn't seem to have any facilities to do that.
 
 any ideas ?

i am wondering ... the voicemail app, does something similar.

In voicemail.conf you can specify the minlength of message to it will be
processed:

voicemail.conf
; Minimum length of a voicemail message in seconds for the message to be
; kept
; The default is no minimum.
minmessage=3

Maybe one can have a look at the code of the voicemail-App and tranfer
it do the record-App ??

Has this some chance of success ?

Tobias
___
--Bandwidth and Colocation provided by Easynews.com --

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


RE: [asterisk-users] sound file length

2006-09-22 Thread Race Vanderdecken
Good Thinking, the code is only about 5 lines.

As to the WAVE RIFF file being funny. Well, you have to know a little
about the car you are working on to know if you need metric or Standard
wrenches and which dealership to get parts from.

But the basic idea works. Some many bytes per second means a file of x
bytes of y format is z seconds long. 

Geez, how accurate does the length have to be? 1.98 is to short but
1.985 is long enough.

Asterisk only records in a few formats, GSM, WAVE and something else at
times.

If you need help, drop me a line and I will help you discover how many
bytes makes up 1 second or x seconds...

Later.

Race Vanderdecken
Code Tyrant

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Tobias
Wolf
Sent: Friday, September 22, 2006 5:05 AM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [asterisk-users] sound file length

Raphael Jacquot schrieb:
 At some point in my dial plan, I need to find out the length of a
sound
 file in seconds (to weed out things that are way too short)
 
 the record application doesn't seem to have any facilities to do that.
 
 any ideas ?

i am wondering ... the voicemail app, does something similar.

In voicemail.conf you can specify the minlength of message to it will be
processed:

voicemail.conf
; Minimum length of a voicemail message in seconds for the message to be
; kept
; The default is no minimum.
minmessage=3

Maybe one can have a look at the code of the voicemail-App and tranfer
it do the record-App ??

Has this some chance of success ?

Tobias
___
--Bandwidth and Colocation provided by Easynews.com --

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


___
--Bandwidth and Colocation provided by Easynews.com --

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


RE: [asterisk-users] sound file length

2006-09-21 Thread Race Vanderdecken
If it is a wav file you can take the size of the file in bytes and
subtract 44.

So if the file is 5 seconds long, and is 16 bit Linera PCM (uncompressed
ulaw), it contains  80,044 bytes.

Length = 80,044 - 44 = 80,

16,000 bytes / second is uncompressed ulaw, i.e. G.711

8/ 5 = 16,000 bytes per second

so if you do this:

(size - 44 ) / 16 = time in seconds.

(80,044 - 44) / 16 = 5 seconds

So if you want the file to be more than 2 seconds to be good. Do this

2 * 16,000 + 44 = 32,044 bytes. 

So if the file size is greater than 32,000 bytes you have a good file.
Any thing less then 32,000 bytes would fall under the 2 second
threshold.

How you get the size of the file is up to you.

What language are you using? API?

-Race



Race Vanderdecken
Code Tyrant
Somewhere near Asheville, NC.
 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Raphael
Jacquot
Sent: Tuesday, September 12, 2006 6:13 PM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: [asterisk-users] sound file length

At some point in my dial plan, I need to find out the length of a sound 
file in seconds (to weed out things that are way too short)

the record application doesn't seem to have any facilities to do that.

any ideas ?
___
--Bandwidth and Colocation provided by Easynews.com --

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


___
--Bandwidth and Colocation provided by Easynews.com --

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [asterisk-users] sound file length

2006-09-21 Thread John Marvin

Race Vanderdecken wrote:

If it is a wav file you can take the size of the file in bytes and
subtract 44.



This is a hot button of mine. This is a heuristic that may work for many 
wav files, but is not true for others. A wav file header can be larger 
than 44 bytes, the wav data doesn't have to start right after the 
header, and many wav files contain meta data after the wav file data 
(and techically meta data could come before the audio data, but I've 
never seen that before). Some very poorly written wav file playing 
programs will play right through that meta data as if it was audio data.


John
___
--Bandwidth and Colocation provided by Easynews.com --

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [asterisk-users] sound file length

2006-09-12 Thread Time Bandit

At some point in my dial plan, I need to find out the length of a sound
file in seconds (to weed out things that are way too short)

the record application doesn't seem to have any facilities to do that.

any ideas ?

use sox beep.wav -e stat and parse the output

man is your friend
google also :)
___
--Bandwidth and Colocation provided by Easynews.com --

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [asterisk-users] sound file length

2006-09-12 Thread Raphael Jacquot

Time Bandit wrote:

At some point in my dial plan, I need to find out the length of a sound
file in seconds (to weed out things that are way too short)

the record application doesn't seem to have any facilities to do that.

any ideas ?

use sox beep.wav -e stat and parse the output

man is your friend
google also :)


something like this works... but is rather inefficient ...

#!/bin/bash
LENGTH=`sox /home/asterisk/$1.wav -e stat 21 | grep Length | sed -e 
s/[^0-9]*//`;
psql -c update conferences set message_length=$LENGTH where 
conf_serial=12 -U asterisk asterisk

___
--Bandwidth and Colocation provided by Easynews.com --

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users