<?xml-stylesheet type="text/xsl" href="http://coco-lab.org/Elgg/timo/weblog/rss/audio/rssstyles.xsl"?>

<rss version='2.0'   xmlns:dc='http://purl.org/dc/elements/1.1/'>        
    <channel xml:base='http://coco-lab.org/Elgg/timo/weblog/'>
        <title><![CDATA[Timo Baumann : Weblog items tagged with audio]]></title>
        <description><![CDATA[The weblog for Timo Baumann, hosted on Coco-Lab Weblog.]]></description>
        <link>http://coco-lab.org/Elgg/timo/weblog/</link>        
        <item>
            <title><![CDATA[aggregated audio duration]]></title>
            <link>http://coco-lab.org/Elgg/timo/weblog/82.html</link>
            <guid isPermaLink="true">http://coco-lab.org/Elgg/timo/weblog/82.html</guid>
            <pubDate>Sat, 17 Apr 2010 12:55:31 GMT</pubDate>
		<dc:subject><![CDATA[perl]]></dc:subject>
		<dc:subject><![CDATA[audio]]></dc:subject>
            <description><![CDATA[<p>I&#39;ve finally written the one script that was missing from the interwebs and that I have longed to have for so long: </p> <div style="background-color: lightgray; font-family: monospace; line-height: 110%"><p>#!/usr/bin/perl<br /># Copyright (C) 2010 Timo Baumann<br /># This program is free software; you can redistribute it and/or modify it <br /># under the terms of the GNU General Public License as published by the <br /># Free Software Foundation; either version 2 of the License, <br /># or (at your option) any later version.<br /># <br /># This program is distributed in the hope that it will be useful, <br /># but WITHOUT ANY WARRANTY; without even the implied warranty of <br /># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. <br /># See the GNU General Public License for more details.<br /># <br /># You should have received a copy of the GNU General Public License <br /># along with this program; if not, see &lt;<a href="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a>&gt;.</p><p>use strict;<br />use warnings;<br />use Audio::Wav;<br />use Audio::Wav::Read;<br /><br />#usage: audio-duration.pl path-or-file1 path-or-file2 ...<br /><br />my @files;<br />for my $arg (@ARGV) {<br />&nbsp;&nbsp; &nbsp;my $findresult = `find $arg`;<br />&nbsp;&nbsp; &nbsp;push @files, grep /.wav$/, split &quot; &quot;, $findresult;<br />}<br />#print join &quot; &quot;, @files;<br />my $duration = 0.0;<br />my $wav = new Audio::Wav;<br />for my $file (@files) {<br />&nbsp;&nbsp; &nbsp;my $read = $wav-&gt;read($file);<br />&nbsp;&nbsp; &nbsp;$duration += $read-&gt;length_seconds();<br />}<br /># convert to something readable<br />my $readableDuration = &quot;&quot;;<br />if ($duration &gt; 600) {<br />&nbsp;&nbsp; &nbsp;my $seconds = int($duration + .5);<br />&nbsp;&nbsp; &nbsp;my $minutes = int($duration / 60);<br />&nbsp;&nbsp; &nbsp;$seconds -= $minutes * 60;<br />&nbsp;&nbsp; &nbsp;my $hours = int($minutes / 60);<br />&nbsp;&nbsp; &nbsp;$minutes -= $hours * 60;<br />&nbsp;&nbsp; &nbsp;$readableDuration = &quot;(&quot; . ($hours &gt; 0 ? &quot;$hours:&quot; : &quot;&quot;) . &quot;$minutes&#39;$seconds&quot;) &quot;;<br />}<br />print &quot;$duration seconds &quot;, $readableDuration, &quot;in &quot;, ($#files + 1), &quot; wave files.n&quot;;</p></div> <p>Running this in any directory wil yield the duration of audio (only .wav files) of all the files in this directory. If you supply arguments, it will look into the given directories (or files) and tell you the summed duration.</p><p>A must-have for any corpus-linguist dealing with loads of audio files! </p>]]></description>
        </item>
        
    </channel>
</rss>
