transcription/website/youtube-dl.sh
2021-03-27 10:08:19 +01:00

28 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
touch log_ydl.txt
echo " $(date) ###### start conversion __ $1 __ $2" >> log_ydl.txt
UNIQID=$1
mkdir -p ../input/ydl
rm -rf ../input/ydl/$UNIQID.mp3
rm -rf ../input/ydl/$UNIQID
URL=$2
OUTPUT="../input/ydl/$UNIQID/base.mp3"
mkdir ../input/ydl/$UNIQID
youtube-dl --extract-audio --audio-format mp3 --audio-quality 0 --output $OUTPUT $URL
ffmpeg -i "../input/ydl/$UNIQID/base.mp3" -ac 1 "../input/ydl/$UNIQID/mono_canal.wav"
cd ..
OUT_DIR="input/ydl/$UNIQID"
python3 ./conversion_simple_fr.py $OUT_DIR/mono_canal.wav > $OUT_DIR/0_output_$FILE_NAME.json
jq .text $OUT_DIR/0_output_$FILE_NAME.json > $OUT_DIR/1_converted_$FILE_NAME.txt
sed 's/null//g' $OUT_DIR/1_converted_$FILE_NAME.txt > $OUT_DIR/2_without_nulls_$FILE_NAME.txt
sed 's/^ *//; s/ *$//; /^$/d' $OUT_DIR/2_without_nulls_$FILE_NAME.txt > $OUT_DIR/3_without_nulls_$FILE_NAME.txt
sed 's/\"//g' $OUT_DIR/3_without_nulls_$FILE_NAME.txt > $OUT_DIR/4_phrases_$FILE_NAME.txt
ls -l $OUT_DIR >> log_ydl.txt
echo " $(date) ###### end conversion __ $1 __ $2" >> log_ydl.txt