android - How to use wit.ai with ogg files -


i trying use wit.ai speech text able convert recorded audio whatsapp text, problem keep getting error.

wit.ai supports 'audio/wav', 'audio/mpeg3', 'audio/ulaw' , 'audio/raw' content-type header. in case audio/raw used have supply these parameters: encoding, bits, rate, , endian

the file getting whatsapp .ogg.

since don't support kind of file tried audio/raw possible variations keep getting same error:

{   "error" : "bad request",   "code" : "bad-request" }   

when try different type (audio/wav example) getting different error makes sense:

{   "error" : "mismatch between provided content-type , bytes sent.\nare sure it's valid sound file?",   "code" : "content-type-mismatch" }  

for getting file doing:

intent intent = getintent();  string action = intent.getaction();  string type = intent.gettype();   log.w("myapp", "got intent");  if (intent.action_send.equals(action) && type != null) {      audiouri = (uri) intent.getparcelableextra(intent.extra_stream); 

for reading file 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 = fis.read(buf)))             baos.write(buf, 0, n);     } catch (exception e) {         e.printstacktrace();     }     log.w("myapp", integer.tostring(baos.tobytearray().length));      return baos.tobytearray(); 

what doing wrong?

convert ogg pcm libvorbis-libogg-android , send audio/raw requests.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -