Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sed compatibility #2981

Merged
merged 11 commits into from
Mar 8, 2019
13 changes: 5 additions & 8 deletions egs/ami/s5/local/ami_ihm_scoring_data_prep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,15 @@ sort -k 2 $dir/utt2spk | utils/utt2spk_to_spk2utt.pl > $dir/spk2utt || exit 1;
join $dir/utt2spk $dir/segments | \
perl -ne '{BEGIN{$pu=""; $pt=0.0;} split;
if ($pu eq $_[1] && $pt > $_[3]) {
print "$_[0] $_[2] $_[3] $_[4]>$_[0] $_[2] $pt $_[4]\n"
print "s/^$_[0] $_[2] $_[3] $_[4]\$/$_[0] $_[2] $pt $_[4]/;\n"
}
$pu=$_[1]; $pt=$_[4];
$pu=$_[1]; $pt=$_[4];
}' > $dir/segments_to_fix
if [ `cat $dir/segments_to_fix | wc -l` -gt 0 ]; then

if [ -s $dir/segments_to_fix ]; then
echo "$0. Applying following fixes to segments"
cat $dir/segments_to_fix
while read line; do
p1=`echo $line | awk -F'>' '{print $1}'`
p2=`echo $line | awk -F'>' '{print $2}'`
sed -ir "s!$p1!$p2!" $dir/segments
done < $dir/segments_to_fix
perl -i -pf $dir/segments_to_fix $dir/segments
fi

# Copy stuff into its final locations
Expand Down
10 changes: 3 additions & 7 deletions egs/ami/s5/local/ami_mdm_scoring_data_prep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,15 @@ awk '{print $1}' $tmpdir/segments | \
join $tmpdir/utt2spk_stm $tmpdir/segments | \
awk '{ utt=$1; spk=$2; wav=$3; t_beg=$4; t_end=$5;
if(spk_prev == spk && t_end_prev > t_beg) {
print utt, wav, t_beg, t_end">"utt, wav, t_end_prev, t_end;
print "s/^"utt, wav, t_beg, t_end"$/"utt, wav, t_end_prev, t_end"/;";
}
spk_prev=spk; t_end_prev=t_end;
}' > $tmpdir/segments_to_fix

if [ `cat $tmpdir/segments_to_fix | wc -l` -gt 0 ]; then
if [ -s $tmpdir/segments_to_fix ]; then
echo "$0. Applying following fixes to segments"
cat $tmpdir/segments_to_fix
while read line; do
p1=`echo $line | awk -F'>' '{print $1}'`
p2=`echo $line | awk -F'>' '{print $2}'`
sed -ir "s:$p1:$p2:" $tmpdir/segments
done < $tmpdir/segments_to_fix
perl -i -pf $tmpdir/segments_to_fix $tmpdir/segments
fi

# Copy stuff into its final locations [this has been moved from the format_data
Expand Down
10 changes: 3 additions & 7 deletions egs/ami/s5/local/ami_sdm_scoring_data_prep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,15 @@ awk '{print $1}' $tmpdir/segments | \
join $tmpdir/utt2spk_stm $tmpdir/segments | \
awk '{ utt=$1; spk=$2; wav=$3; t_beg=$4; t_end=$5;
if(spk_prev == spk && t_end_prev > t_beg) {
print utt, wav, t_beg, t_end">"utt, wav, t_end_prev, t_end;
print "s/^"utt, wav, t_beg, t_end"$/"utt, wav, t_end_prev, t_end"/;";
}
spk_prev=spk; t_end_prev=t_end;
}' > $tmpdir/segments_to_fix

if [ `cat $tmpdir/segments_to_fix | wc -l` -gt 0 ]; then
if [ -s $tmpdir/segments_to_fix ]; then
echo "$0. Applying following fixes to segments"
cat $tmpdir/segments_to_fix
while read line; do
p1=`echo $line | awk -F'>' '{print $1}'`
p2=`echo $line | awk -F'>' '{print $2}'`
sed -ir "s:$p1:$p2:" $tmpdir/segments
done < $tmpdir/segments_to_fix
perl -i -pf $tmpdir/segments_to_fix $tmpdir/segments
fi

# Copy stuff into its final locations [this has been moved from the format_data
Expand Down
11 changes: 4 additions & 7 deletions egs/ami/s5b/local/ami_ihm_scoring_data_prep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,15 @@ sort -k 2 $dir/utt2spk | utils/utt2spk_to_spk2utt.pl > $dir/spk2utt || exit 1;
join $dir/utt2spk $dir/segments | \
perl -ne '{BEGIN{$pu=""; $pt=0.0;} split;
if ($pu eq $_[1] && $pt > $_[3]) {
print "$_[0] $_[2] $_[3] $_[4]>$_[0] $_[2] $pt $_[4]\n"
print "s/^$_[0] $_[2] $_[3] $_[4]\$/$_[0] $_[2] $pt $_[4]/;\n"
}
$pu=$_[1]; $pt=$_[4];
}' > $dir/segments_to_fix
if [ `cat $dir/segments_to_fix | wc -l` -gt 0 ]; then

if [ -s $dir/segments_to_fix ]; then
echo "$0. Applying following fixes to segments"
cat $dir/segments_to_fix
while read line; do
p1=`echo $line | awk -F'>' '{print $1}'`
p2=`echo $line | awk -F'>' '{print $2}'`
sed -ir "s!$p1!$p2!" $dir/segments
done < $dir/segments_to_fix
perl -i -pf $dir/segments_to_fix $dir/segments
fi

# Copy stuff into its final locations
Expand Down
10 changes: 3 additions & 7 deletions egs/ami/s5b/local/ami_mdm_scoring_data_prep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,15 @@ awk '{print $1}' $tmpdir/segments | \
join $tmpdir/utt2spk_stm $tmpdir/segments | \
awk '{ utt=$1; spk=$2; wav=$3; t_beg=$4; t_end=$5;
if(spk_prev == spk && t_end_prev > t_beg) {
print utt, wav, t_beg, t_end">"utt, wav, t_end_prev, t_end;
print "s/^"utt, wav, t_beg, t_end"$/"utt, wav, t_end_prev, t_end"/;";
}
spk_prev=spk; t_end_prev=t_end;
}' > $tmpdir/segments_to_fix

if [ `cat $tmpdir/segments_to_fix | wc -l` -gt 0 ]; then
if [ -s $tmpdir/segments_to_fix ]; then
echo "$0. Applying following fixes to segments"
cat $tmpdir/segments_to_fix
while read line; do
p1=`echo $line | awk -F'>' '{print $1}'`
p2=`echo $line | awk -F'>' '{print $2}'`
sed -ir "s:$p1:$p2:" $tmpdir/segments
done < $tmpdir/segments_to_fix
perl -i -pf $tmpdir/segments_to_fix $tmpdir/segments
fi

# Copy stuff into its final locations [this has been moved from the format_data
Expand Down
12 changes: 4 additions & 8 deletions egs/ami/s5b/local/ami_sdm_scoring_data_prep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,25 +111,21 @@ awk '{print $1}' $tmpdir/segments | \
join $tmpdir/utt2spk_stm $tmpdir/segments | \
awk '{ utt=$1; spk=$2; wav=$3; t_beg=$4; t_end=$5;
if(spk_prev == spk && t_end_prev > t_beg) {
print utt, wav, t_beg, t_end">"utt, wav, t_end_prev, t_end;
print "s/^"utt, wav, t_beg, t_end"$/"utt, wav, t_end_prev, t_end"/;";
}
spk_prev=spk; t_end_prev=t_end;
}' > $tmpdir/segments_to_fix

if [ `cat $tmpdir/segments_to_fix | wc -l` -gt 0 ]; then
if [ -s $tmpdir/segments_to_fix ]; then
echo "$0. Applying following fixes to segments"
cat $tmpdir/segments_to_fix
while read line; do
p1=`echo $line | awk -F'>' '{print $1}'`
p2=`echo $line | awk -F'>' '{print $2}'`
sed -ir "s:$p1:$p2:" $tmpdir/segments
done < $tmpdir/segments_to_fix
perl -i -pf $tmpdir/segments_to_fix $tmpdir/segments
fi

# Copy stuff into its final locations [this has been moved from the format_data
# script]
mkdir -p $dir
for f in spk2utt utt2spk utt2spk_stm wav.scp text segments reco2file_and_channel; do
for f in segments_to_fix spk2utt utt2spk utt2spk_stm wav.scp text segments reco2file_and_channel; do
cp $tmpdir/$f $dir/$f || exit 1;
done

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ cp ${output_dir}_non_normalized/info/* $output_dir/info

# rename file location in the noise-rir pairing files
for file in `ls $output_dir/info/noise_impulse*`; do
sed -i "s/_non_normalized//g" $file
perl -i -pe "s/_non_normalized//g" $file
done

# generating the rir-list with probabilities alloted for each rir
Expand Down
3 changes: 1 addition & 2 deletions egs/babel/s5c/local/syllab/generate_syllable_lang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ ln -s lex.syllabs2phones.disambig.fst $out/L_disambig.fst
echo "Validating the output lang dir"
utils/validate_lang.pl $out || exit 1

sed -i'' 's/#1$//g' $lout/lexicon.txt
sed -i'' 's/#1$//g' $lout/lexiconp.txt
perl -i -pe 's/#1$//g' $lout/lexicon.txt $lout/lexiconp.txt

echo "Done OK."
exit 0
3 changes: 1 addition & 2 deletions egs/babel/s5d/local/syllab/generate_phone_lang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ ln -s lex.syllabs2phones.disambig.fst $out/L_disambig.fst
echo "Validating the output lang dir"
utils/validate_lang.pl $out || exit 1

sed -i'' 's/#1$//g' $lout/lexicon.txt
sed -i'' 's/#1$//g' $lout/lexiconp.txt
perl -i -pe 's/#1$//g' $lout/lexicon.txt $lout/lexiconp.txt

echo "Done OK."
exit 0
3 changes: 1 addition & 2 deletions egs/babel/s5d/local/syllab/generate_syllable_lang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ ln -s lex.syllabs2phones.disambig.fst $out/L_disambig.fst
echo "Validating the output lang dir"
utils/validate_lang.pl $out || exit 1

sed -i'' 's/#1$//g' $lout/lexicon.txt
sed -i'' 's/#1$//g' $lout/lexiconp.txt
perl -i -pe 's/#1$//g' $lout/lexicon.txt $lout/lexiconp.txt

echo "Done OK."
exit 0
6 changes: 2 additions & 4 deletions egs/bentham/v1/local/create_splits.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ function split {
echo $name $lines_dir"/"$name".png" >> $split_dir/images.scp
echo $name $spkid >> $split_dir/utt2spk
done < "$line_file"

sed -i '/^\s*$/d' $split_dir/images.scp
sed -i '/^\s*$/d' $split_dir/text
sed -i '/^\s*$/d' $split_dir/utt2spk

perl -i -ne 'print if /\S/' $split_dir/images.scp $split_dir/text $split_dir/utt2spk
utils/utt2spk_to_spk2utt.pl $split_dir/utt2spk > $split_dir/spk2utt
}

Expand Down
5 changes: 2 additions & 3 deletions egs/callhome_egyptian/s5/local/callhome_prepare_dict.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ cat $dir/silence_phones.txt| awk '{printf("%s ", $1);} END{printf "\n";}' > \
$dir/extra_questions.txt || exit 1;

# Add prons for laughter, noise, oov
for w in `grep -v sil $dir/silence_phones.txt`; do
sed -i "/\[$w\]/d" $tmpdir/lexicon.3
done
w=$(grep -v sil $dir/silence_phones.txt | tr '\n' '|')
perl -i -ne "print unless /\[(${w%?})\]/" $tmpdir/lexicon.3

for w in `grep -v sil $dir/silence_phones.txt`; do
echo "[$w] $w"
Expand Down
6 changes: 3 additions & 3 deletions egs/callhome_egyptian/s5/local/ctm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ fi
steps/get_ctm.sh $data_dir $lang_dir $decode_dir

# Make sure that channel markers match
#sed -i "s:\s.*_fsp-([AB]): \1:g" data/dev/stm
#ls exp/tri5a/decode_dev/score_*/dev.ctm | xargs -I {} sed -i -r 's:fsp\s1\s:fsp A :g' {}
#ls exp/tri5a/decode_dev/score_*/dev.ctm | xargs -I {} sed -i -r 's:fsp\s2\s:fsp B :g' {}
#perl -i -pe "s:\s.*_fsp-([AB]): \1:g" data/dev/stm
#ls exp/tri5a/decode_dev/score_*/dev.ctm | xargs -I {} perl -i -pe 's:fsp\s1\s:fsp A :g' {}
#ls exp/tri5a/decode_dev/score_*/dev.ctm | xargs -I {} perl -i -pe 's:fsp\s2\s:fsp B :g' {}

# Get the environment variables
. /export/babel/data/software/env.sh
Expand Down
6 changes: 3 additions & 3 deletions egs/fisher_callhome_spanish/s5/local/ctm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ fi
steps/get_ctm.sh $data_dir $lang_dir $decode_dir

# Make sure that channel markers match
#sed -i "s:\s.*_fsp-([AB]): \1:g" data/dev/stm
#ls exp/tri5a/decode_dev/score_*/dev.ctm | xargs -I {} sed -i -r 's:fsp\s1\s:fsp A :g' {}
#ls exp/tri5a/decode_dev/score_*/dev.ctm | xargs -I {} sed -i -r 's:fsp\s2\s:fsp B :g' {}
#perl -i -pe "s:\s.*_fsp-([AB]): \1:g" data/dev/stm
#ls exp/tri5a/decode_dev/score_*/dev.ctm | xargs -I {} perl -i -pe 's:fsp\s1\s:fsp A :g' {}
#ls exp/tri5a/decode_dev/score_*/dev.ctm | xargs -I {} perl -i -pe 's:fsp\s2\s:fsp B :g' {}

# Get the environment variables
. /export/babel/data/software/env.sh
Expand Down
5 changes: 2 additions & 3 deletions egs/fisher_callhome_spanish/s5/local/fsp_prepare_dict.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,8 @@ if [ $stage -le 4 ]; then
cp "$tmpdir/lexicon.1" "$tmpdir/lexicon.2"

# Add prons for laughter, noise, oov
for w in `grep -v sil $dir/silence_phones.txt`; do
sed -i "/\[$w\]/d" $tmpdir/lexicon.2
done
w=$(grep -v sil $dir/silence_phones.txt | tr '\n' '|')
perl -i -ne "print unless /\[(${w%?})\]/" $tmpdir/lexicon.2

for w in `grep -v sil $dir/silence_phones.txt`; do
echo "[$w] $w"
Expand Down
3 changes: 1 addition & 2 deletions egs/gale_arabic/s5/local/gale_prep_dict.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ echo SIL > $dir/optional_silence.txt
cat $dir/lexicon.txt | cut -d ' ' -f2- | tr -s ' ' '\n' |\
sort -u > $dir/nonsilence_phones.txt || exit 1;

perl -i -pe 'print "<UNK> SIL\n" if $.==1' $dir/lexicon.txt

sed -i '1i<UNK> SIL' $dir/lexicon.txt

echo Dictionary preparation succeeded

exit 0
2 changes: 1 addition & 1 deletion egs/iam/v1/local/prepare_dict.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ while(<>){
}' | sort -u > $dir/lexicon.txt


sed -i "s/#/<HASH>/" $dir/nonsilence_phones.txt
perl -i -pe "s/#/<HASH>/" $dir/nonsilence_phones.txt

echo '<sil> SIL' >> $dir/lexicon.txt
echo '<unk> SIL' >> $dir/lexicon.txt
Expand Down
2 changes: 1 addition & 1 deletion egs/iam/v2/local/prepare_dict.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ while(<>){
}' | sort -u > $dir/lexicon.txt


sed -i "s/#/<HASH>/" $dir/nonsilence_phones.txt
perl -i -pe "s/#/<HASH>/" $dir/nonsilence_phones.txt

echo '<sil> SIL' >> $dir/lexicon.txt

Expand Down
14 changes: 7 additions & 7 deletions egs/reverb/s5/local/download_se_eval_tool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ unzip REVERB_scores.zip -d local/REVERB_scores_source
rm REVERB_scores.zip

pushd local/REVERB_scores_source/REVERB-SPEENHA.Release04Oct/evaltools
sed -i 's/wavread/audioread/g' prog/score_sim.m
perl -i -pe 's/wavread/audioread/g' prog/score_sim.m
git clone https://github.com/MuSAELab/SRMRToolbox.git
sed -i 's/wavread/audioread/g' SRMRToolbox/libs/preprocess.m
sed -i 's/SRMR_main/SRMR/g' prog/score_real.m
sed -i 's/SRMR_main/SRMR/g' prog/score_sim.m
sed -i 's/+wb\ //g' prog/calcpesq.m
sed -i 's/pesq_/_pesq_/g' prog/calcpesq.m
sed -ie '30d;31d' prog/calcpesq.m
perl -i -pe 's/wavread/audioread/g' SRMRToolbox/libs/preprocess.m
perl -i -pe 's/SRMR_main/SRMR/g' prog/score_real.m
perl -i -pe 's/SRMR_main/SRMR/g' prog/score_sim.m
perl -i -pe 's/\+wb //g' prog/calcpesq.m
perl -i -pe 's/pesq_/_pesq_/g' prog/calcpesq.m
perl -n -i -e 'print unless /remove target file name/' prog/calcpesq.m
patch score_RealData.m -i ../../../score_RealData.patch -o score_RealData_new.m
mv score_RealData_new.m score_RealData.m
patch score_SimData.m -i ../../../score_SimData.patch -o score_SimData_new.m
Expand Down
2 changes: 1 addition & 1 deletion egs/yomdle_fa/v1/local/prepare_dict.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ mkdir -p $dir

local/prepare_lexicon.py --data-dir $data_dir $dir

sed -i '/^\s*$/d' $dir/lexicon.txt
perl -i -ne 'print if /\S/' $dir/lexicon.txt
cut -d' ' -f2- $dir/lexicon.txt | sed 's/SIL//g' | tr ' ' '\n' | sort -u | sed '/^$/d' >$dir/nonsilence_phones.txt || exit 1;

echo '<sil> SIL' >> $dir/lexicon.txt
Expand Down
2 changes: 1 addition & 1 deletion egs/yomdle_zh/v1/local/create_download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ local/create_line_image_from_page_image.py \

echo "Downloading table for CangJie."
wget -P $download_dir/ $cangjie_url || exit 1;
sed -ie '1,8d' $download_dir/cj5-cc.txt
desh2608 marked this conversation as resolved.
Show resolved Hide resolved
perl -n -i -e 'print if $. > 8' $download_dir/cj5-cc.txt
2 changes: 1 addition & 1 deletion tools/extras/install_portaudio.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ if [ -z "$MACOS" ]; then
fi

./configure --prefix=`pwd`/install --with-pic
sed -i.bk '40s:src/common/pa_ringbuffer.o::g; 40s:$: src/common/pa_ringbuffer.o:' Makefile
perl -i -pe 's:src/common/pa_ringbuffer.o:: if /^OTHER_OBJS\s*=/' Makefile

if [ "$MACOS" != "" ]; then
echo "detected MacOS operating system ... trying to fix Makefile"
Expand Down