Hello, I would like to run a script over a speex file which determines, how long the speech contained in the speex file is. So I run through the ogg file, skip the first two ogg _pages_ (speex header and comment header, both contain IMHO only 1 ogg _packet_), and then count in any ogg page the number of the ogg _frames_ (which, unless I used -nframes while encoding, which I did not), and multiply this with .02 (20 milliseconds). I did this by hand, for example on the file I send yesterday when asking about the noise, so the output of the program is: $ readspx spfe49_1-small.spx speex header Version:1.1.12 rate:44100 mode:2 mode_bitstream_version:4 nb_channels:2 bitrate:-1 frame_size:640 vbr:0 frames_per_packet:1 extra_headers:0 Page #2: 1 packets. Page #3: 45 packets. Page #4: 45 packets. Page #5: 45 packets. Page #6: 45 packets. Page #7: 45 packets. Page #8: 45 packets. Pages: 8 Packets: 272 Calculating things per hand here 6*45 speex frames, so the speech length should be 5.4 seconds. Unfortunately this is overestimated: $ time speexdec spfe49_1-small.spx Decoding 44100 Hz audio using ultra-wideband (sub-band CELP) mode (stereo) Encoded with Speex 1.1.12 real 0m3.992s user 0m0.112s sys 0m0.020s So my questions are: What does the "frame_size: 640" mean (the information was simply read out with speex_header->frame_size). Why does my algorithm for calculating the length of the speech in a speex file not work? How is the number of ogg _packets_ per ogg _frame_ set by the encoder (commandline, file-based)? Ciao, Bj?rn -- Q: What's the difference betweeen USL and the Graf Zeppelin? A: The Graf Zeppelin represented cutting edge technology for its time. -- Important! Please recognize my new GPG Public Key! Bj?rn Thalheim gpg fingerprint: 2F22 AAEB 1818 1548 EC78 1AE8 9D2E FCB4 0980 28CC download key: wget http://www.ifsr.de/~bjoern/gpg/public_key.asc See also: http://www.ifsr.de/~bjoern/gpg/key.html -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 256 bytes Desc: OpenPGP digital signature Url : http://lists.xiph.org/pipermail/speex-dev/attachments/20060516/a08761d5/signature.pgp
On Tue, May 16, 2006 at 03:29:47PM +0200, Bj?rn Thalheim wrote:> > I would like to run a script over a speex file which determines, how > long the speech contained in the speex file is. > So I run through the ogg file, skip the first two ogg _pages_ (speex > header and comment header, both contain IMHO only 1 ogg _packet_), and > then count in any ogg page the number of the ogg _frames_ (which, unless > I used -nframes while encoding, which I did not), and multiply this with > .02 (20 milliseconds). > I did this by hand, for example on the file I send yesterday when asking > about the noise, so the output of the program is: > > $ readspx spfe49_1-small.spx > speex header > Version:1.1.12 > rate:44100 > mode:2 > mode_bitstream_version:4 > nb_channels:2 > bitrate:-1 > frame_size:640 > vbr:0 > frames_per_packet:1 > extra_headers:0 > Page #2: 1 packets. > Page #3: 45 packets. > Page #4: 45 packets. > Page #5: 45 packets. > Page #6: 45 packets. > Page #7: 45 packets. > Page #8: 45 packets. > Pages: 8 > Packets: 272 > > Calculating things per hand here 6*45 speex frames, so the speech length > should be 5.4 seconds. Unfortunately this is overestimated:Hi Bj?rn, The number of pages is irrelevent. Pages are just the container that stores packets, and the number of packets in each page could vary. You only need to keep track of the number of packets in the file. Then: encoded_speex_frames = (frames_per_packet * Packets) = 1 * 272 = 272 audio_samples = encoded_speex_frames * frame_size = 272 * 640 = 174080 duration = audio_samples / rate = 174080 / 44100 = 3.947 cheers, Conrad.
Skipped content of type multipart/mixed-------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 256 bytes Desc: OpenPGP digital signature Url : http://lists.xiph.org/pipermail/speex-dev/attachments/20060519/452f0fed/signature.pgp