#!/bin/sh
#
# demo_waveforms.sh:
#
# Chop switchboard waveforms into utterance units
#

# First, find all of the utterance-level transcription files
CONVDIR=c:/switchboard_dat/conv;
makescripts.pl text $CONVDIR > scp/HCopy.scp;
ask '/word/{};/trans/{print;}' scp/HCopy.scp > scp/swb-trans.scp

# Next, combine all of the utterance-level files into an MLF
sphere2mlf.pl scp/swb-trans.scp 1 text > mlf/swb-trans.mlf
sed '/\/sw/s/-ms98-a-trans//;/\/sw/s/sw/SW0/' <mlf/swb-trans.mlf>mlf/chop_speech.mlf

# Create a script specifying the waveform files
# SPEECHDIR is the directory in which Switchboard distribution is stored
SPEECHDIR=c:/switchboard_dat/speech;
ls $SPEECHDIR/*/* | perl -e 'while($l=<STDIN>){$o=$l; $o=~s/\..*//; $o=~s/speech/chopped_speech/; print "$l $o\n"}' > scp/chop_speech.scp

# Chop the waveforms
chop_waveform.pl mlf/chop_speech.mlf scp/chop_speech.scp cfg/HCopy.cfg

