How to use with ogg files

I am trying to use the speech to text so I will be able to convert recorded audio from whatsapp into text, The problem is that I keep getting error. supports ‘audio/wav’, ‘audio/mpeg3’, ‘audio/ulaw’ and ‘audio/raw’ for the Content-Type header. In case audio/raw is used you also have to supply these parameters: encoding, bits, rate, and endian

The file I am getting from whatsapp is .ogg.

Since they don’t support this kind of file I tried the audio/raw with all possible variations but I keep getting the same error:

  "error" : "Bad request",
  "code" : "bad-request"

When I try a different type (audio/wav for example) I am getting a different error which makes sense:

  "error" : "Mismatch between the provided content-type and the bytes you sent./nAre you sure it's a valid sound file?",
  "code" : "content-type-mismatch"

For getting the file I am doing:

Intent intent = getIntent();
 String action = intent.getAction();
 String type = intent.getType();

 Log.w("myapp", "got the intent");
 if (Intent.ACTION_SEND.equals(action) && type != null) {
     audioUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);

For reading the file I am doing:

InputStream inputStream = getContentResolver().openInputStream(uri);
    String type = getContentResolver().getType(uri);

    Log.w("myapp", "type of file: " + type);

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    InputStream fis = getContentResolver().openInputStream(uri);
    try {
        byte[] buf = new byte[1024];
        int n;
        while (-1 != (n =
            baos.write(buf, 0, n);
    } catch (Exception e) {
    Log.w("myapp", Integer.toString(baos.toByteArray().length));

    return baos.toByteArray();

What am I doing wrong?

Convert ogg to PCM with libvorbis-libogg-android and send the audio/raw requests.