-
Notifications
You must be signed in to change notification settings - Fork 5
/
TranscribeVoiceFile2Text.sh
executable file
·60 lines (44 loc) · 1.79 KB
/
TranscribeVoiceFile2Text.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
#!/bin/bash
#Transcribe voice to text via Google Speech to text API via Google Cloud
shopt -s nullglob
export SOURCE_HOME="$HOME"
export SOURCE_PATH_OF_VOICE_MEMO="$HOME/GStorage/GCLLC_STORAGE/Documents/Voice_Recordings"
export SOURCE_PATH_TO_PARTS_FROM_HOME="$HOME/Audio/parts"
export SOURCE_PROJECT_LOCATION="/Projects/github.com/cloned/TranscribeVoiceFile2Text"
export SOURCEFFMPEG="/usr/local/bin/ffmpeg"
export SOURCEPYTHON="/usr/local/bin/python3"
cd $SOURCE_PATH_OF_VOICE_MEMO
for name in *.m4a; do
cd "$SOURCE_HOME"
echo "$name"
rm -fv $SOURCE_PATH_TO_PARTS_FROM_HOME/*.m4a
export SOURCEVMNAME="$SOURCE_PATH_OF_VOICE_MEMO/$name"
export SOURCEVMNAMEOUT="$SOURCE_PATH_TO_PARTS_FROM_HOME/out%09d.m4a"
$SOURCEFFMPEG -nostdin -i "$SOURCEVMNAME" -f segment -segment_time 59 -c copy "$SOURCEVMNAMEOUT"
cd $SOURCE_PATH_TO_PARTS_FROM_HOME
echo $PWD
echo "converting m4a to flac"
for partname in *.m4a; do
echo $partname
export basefilename="${partname%.[^.]*}"
echo $basefilename
export partnameflacdest="$SOURCE_PROJECT_LOCATION/parts/$basefilename.flac"
$SOURCEFFMPEG -nostdin -i "$partname" -c:a flac "$partnameflacdest"
done
#break
cd $SOURCE_PROJECT_LOCATION
$SOURCEPYTHON TranscribeVoiceFile2Text.py
basefilenamevm="${name%.[^.]*}"
export txt=".txt"
export basefilenamevmtxt="$basefilenamevm$txt"
mkdir "./converted/$basefilenamevm"
cp ./transcript.txt "./converted/$basefilenamevm"
cp ./parts/* "./converted/$basefilenamevm"
rm -fv ./parts/*.flac
rm -fv $SOURCE_PATH_TO_PARTS_FROM_HOME/*.m4a
cp ./transcript.txt "$SOURCE_PATH_OF_VOICE_MEMO/transcribed/$basefilenamevmtxt"
rm ./transcript.txt
mv "$SOURCE_PATH_OF_VOICE_MEMO/$name" "$SOURCE_PATH_OF_VOICE_MEMO/transcribed/$name"
#break
done
cd "$SOURCE_HOME"