Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

From .WAV to pitch and amplitude contours

285 views
Skip to first unread message

Michael A. Covington

unread,
Mar 6, 2003, 10:33:20 PM3/6/03
to
What is, at present, the most convenient way to go from a .WAV file to a
file representing the pitch contour (and, if possible, the amplitude
contour) which then would be analyzed further by my own code?

Is it easy to hack Wavesurfer to output these graphs as files of numbers?

Other alternatives? The solution needs to be open-source and/or
noncommercial if possible. Thanks.


--

Michael A. Covington - Associate Director
Artificial Intelligence Center, The University of Georgia
http://www.ai.uga.edu/~mc


Kare Sjolander

unread,
Mar 7, 2003, 8:23:14 AM3/7/03
to
If you only need to do this for a few files you could simply open them in
WaveSurfer, create a pitch contour, right click on it and save the values
using "Save Data File..."
If you have lots of files you might consider using Snack
(http://www.speech.kth.se/snack/). Here's a script that does what you
desire.

package require snack
snack::sound s

# read sound file

set file ex1.wav
s read $file

# create text file with pitch values

set fd [open [file rootname $file].f0 w]
puts $fd [join [s pitch -method esps] \n]
close $fd

# create text file with power values

set fd [open [file rootname $file].pwr w]
puts $fd [join [s power] \n]
close $fd


# create text file with maximum amplitude values, one per 10ms block

set fd [open [file rootname $file].amp w]
set end 159
for {set start 0} {$start < [s length]-160} {incr start 160} {
set max [s max -start $start -end $end]
set min [s min -start $start -end $end]
if {$max > -$min} {
set out $max
} else {
set out -$min
}
puts $fd $out
incr end 160
}
close $fd


More similar examples can be found at
http://www.speech.kth.se/snack/tutorial.html, see the section on batch
processing.

WaveSurfer uses Snack internally so it can also be used to run the Snack
script above. Open the WaveSurfer console, choose File | Source... and open
the script.
It's probably easier to install Snack and use it directly though.


Hacking WaveSurfer is probably the most difficult option.
The following commands typed in the console will perform pitch extraction
set w [wsurf::GetCurrent]
set s [$w cget -sound]
puts [$s pitch]

In principle you could add a button to the WaveSurfer GUI that executes the
above statements using this statement typed on the console

pack [button .x.b3 -text hej -command [list puts [[[wsurf::GetCurrent] cget
-sound] pitch]]]

but it's probably easier use WaveSurfer's source distribution and add the
line in at the end of wavesurfer.tcl. Note that no compilation is needed.

Kare

Aldebaro Klautau

unread,
Mar 8, 2003, 12:46:28 PM3/8/03
to
I think Snack
http://www.speech.kth.se/snack/
is very convenient for such task.

Aldebaro

0 new messages