-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_subl_mp3.sh
122 lines (80 loc) · 2.88 KB
/
create_subl_mp3.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/bash
base_name=$1
############
# Pre process text
###################
echo "Creating sub texts"
./pronouncer.pl ./text/$base_name.txt
./i2y.pl ./text/$base_name.txt_pronouncer.txt
mkdir text/$base_name\_tmp
cd text/$base_name\_tmp
split -d -l 40 ../$base_name.txt_pronouncer.txt $base_name\_split
split -d -l 40 ../$base_name.txt_pronouncer.txt_you.txt $base_name\_you_split
cd ../../
#################
# Start emulator phase
###############
echo "Starting emulator"
#printf "Run : \n\n ~/Android/Sdk/emulator/emulator -avd Pixel_XL_API_26 -use-system-libs\n\n"
~/Android/Sdk/emulator/emulator -avd Pixel_API_26 -use-system-libs &
echo "Clearing logs"
adb logcat -c
#read -p "Press enter to continue"
echo "Pushing sub texts to emulator"
for i in $(ls ./text/$base_name\_tmp/); do adb push ./text/$base_name\_tmp/$i /sdcard/Download/vance ; done
#adb push ./text/$base_name\_tmp/$base_name.txt_pronouncer.txt /sdcard/Download/$base_name\_i.txt
#adb push ./text/$base_name\_tmp/$base_name.txt_pronouncer.txt_you.txt /sdcard/Download/$base_name\_y.txt
echo "Starting tts2wav activity"
adb shell am start -n com.imaginine.tts2wav.tts2wav/com.imaginine.tts2wav.tts2wav.MainActivity
echo "awaiting all done message"
adb logcat | while read LOGLINE; do [[ "${LOGLINE}" == *"ALL Finished"* ]] && pkill -P $$ adb; done
echo "wavs generated"
echo "Retreiving audio from emulator"
mkdir wav/$base_name\_tmp
cd wav/$base_name\_tmp
adb shell 'ls /sdcard/Download/vance/*.wav' | tr -d '\r' | xargs -n1 adb pull
#adb pull /sdcard/Download/$base_name\_i.wav
#adb pull /sdcard/Download/$base_name\_y.wav
cd ../../
echo "Concatenating audio from emulator"
sox wav/$base_name\_tmp/$base_name\_split0* $base_name\_i.wav
sox wav/$base_name\_tmp/$base_name\_you_split0* $base_name\_y.wav
#############
#
# Build
#
############
echo "Building wav"
#read -p "Press enter to continue"
./build_audio.pl $base_name\_i.wav $base_name\_y.wav $base_name.wav
echo "Creating MP3"
ffmpeg -i $base_name.wav $base_name.mp3
#read -p "Finished building, press enter to continue with cleanup"
#############
#
# Cleanup
#
############
echo "Removing audio from emulator"
#adb shell rm /sdcard/Download/$base_name\_i.wav
#adb shell rm /sdcard/Download/$base_name\_y.wav
echo "Removing texts from emulator"
#adb shell rm /sdcard/Download/$base_name\_i.txt
#adb shell rm /sdcard/Download/$base_name\_y.txt
adb shell rm /sdcard/Download/*
echo "Removing sub texts"
rm ./text/$base_name.txt_pronouncer.txt
rm ./text/$base_name.txt_pronouncer.txt_you.txt
echo "Removing tmp audio"
rm -rf wav/$base_name\_tmp/
echo "Removing tmp text"
rm -rf text/$base_name\_tmp/
echo "Remove I/You wavs"
rm $base_name.wav
echo "Remove output wavs"
rm $base_name\_i.wav
rm $base_name\_y.wav
echo "Clear emulator"
adb shell rm /sdcard/Download/vance/*
echo "Close emulator"
kill `ps aux | grep -v grep | grep emulator | grep qemu | awk '{ print $2 }'`