summaryrefslogblamecommitdiffstats
path: root/skripti/transcribe_large_file.sh
blob: e9bcc27590c24b2807cf81c112fa6b3d668bf640 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14













                                                                                                                                   
#!/bin/bash
set -xeuo pipefail
p=`rev <<<$0 | cut -d/ -f1 | rev`
d=`mktemp -p "" -d $p.XXX`
trap "rm -fr $d" EXIT
ffmpeg -i $1 -f segment -segment_time 240 -acodec pcm_s16le -ac 1 -ar 16000 $d/%03d.wav
for i in $d/*.wav
do
	curl -X 'POST' \
		'http://splet.4a.si.:8000/api/transcribe' \
		-H 'accept: application/json' \
		-H 'Content-Type: multipart/form-data' \
		-F "audio_file=@$i;type=audio/wav" | jq --raw-output .result > $1.`rev <<<$i | cut -d. -f2 | cut -d/ -f1 | rev`.txt
done