I have to send an wave file to wit.ai using http api call.In there documentation they have shown exaple using curl
$ curl -XPOST 'https://api.wit.ai/speech?v=20141022' \
-i -L \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: audio/wav" \
--data-binary "@sample.wav"
I am using java and i have to send this request using java but i am not able to properly convert this curl request in java. i am unable to understand what is -i and -l also how to set data-binary in post request of java.
This what i have done so far
public static void main(String args[])
{
String url = "https://api.wit.ai/speech";
String key = "token";
String param1 = "20170203";
String param2 = command;
String charset = "UTF-8";
String query = String.format("v=%s",
URLEncoder.encode(param1, charset));
URLConnection connection = new URL(url + "?" + query).openConnection();
connection.setRequestProperty ("Authorization","Bearer"+ key);
connection.setRequestProperty("Content-Type", "audio/wav");
InputStream response = connection.getInputStream();
System.out.println( response.toString());
}