forked from CorentinJ/Real-Time-Voice-Cloning
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtts2speech.sh
40 lines (39 loc) · 1.39 KB
/
tts2speech.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
DATASET="$(realpath -s $1)/*/"
for speakers in $DATASET
do
if [ -d "${speakers}" ]; then
speaker=$(basename "${speakers%*/}")
echo "Found speaker: $speakers"
PSPEAKERS="$(realpath -s $speakers)/*/"
for chapters in $PSPEAKERS
do
if [ -d "$chapters" ]; then
chapter=$(basename "$chapters")
echo "Found chapter: $chapter"
outfile="${chapters%/*}/${speaker}-${chapter}.trans.txt"
echo "outfile: $outfile ..."
declare -a trans
audio="${chapters}/*.mp3"
for f in $audio
do
fpath=${f%/*}
fname=${f##*/}
fbase=${fname%.*}
#echo "Processing $fname file... on path $fpath"
#echo "Looking for ${fbase}.txt ..."
tpt="${fpath}/${fbase}.txt"
if [ -f "${tpt}" ]; then
cnt=$(<$tpt)
#echo "Found ${fbase}.txt ..."
trans+=("${fbase} ${cnt^^}")
else
echo "Did not find ${fbase}.txt ..."
fi
done
{ [ "${#trans[@]}" -eq 0 ] || printf '%s\n' "${trans[@]}"; } > $outfile
unset trans
fi
done
fi
done