-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathclientPOSTtext.sh
More file actions
executable file
·39 lines (31 loc) · 1.06 KB
/
clientPOSTtext.sh
File metadata and controls
executable file
·39 lines (31 loc) · 1.06 KB
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
#!/bin/bash
ipaddress="localhost"
port=3000
#speechFile="../audio/2830-3980-0043.pcm"
speechFile="../audio/2830-3980-0043.wav"
#model="vosk-model-en-us-aspire-0.2"
model="vosk-model-small-en-us-0.15"
grammar='["experience proves this","why should one hold on the way","your power is sufficient i said"]'
# get unix timestamp in milliseconds, and use it as request id
id=$(($(date +%s%N)/1000000))
#
# Request:
# POST request, with query string arguments
# HTTP POST /transcript?id='12121212'&speech='filename.wav'& ...
# send audio WAV file as body
#
# Response:
# A JSON is expected
#
# WARNING
# with curl, --data-urlencode and --data-binary can NOT coexists, See:
# https://stackoverflow.com/questions/62578702/mixing-curls-data-binary-and-the-ability-to-encode-url-search-params
# https://stackoverflow.com/questions/296536/how-to-urlencode-data-for-curl-command/298258
quesryArguments="id=$id&model=$model"
curl -s \
-X POST \
-H "Accept: text/plain" \
-H "Content-Type: audio/wav" \
--data-binary "@$speechFile" \
http://$ipaddress:$port/transcript?$queryArguments
echo