Topic
  • 4 replies
  • Latest Post - ‏2012-11-23T18:21:33Z by SystemAdmin
SystemAdmin
SystemAdmin
2327 Posts

Pinned topic How to upload audio file using an HTTP adapter

‏2012-11-14T03:34:49Z |
Hi,

I am new to IBM Worklight. I want to create an application that record the voice on mobile device, upload the audio file to HTTP adapter, then covert the audio to .flac and send it to google server for analysis. I couldn't find any information on uploading files to HTTP adapter, can someone point me to the right direction?

Please find my application architecture in the attachment.

Thanks!!
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: How to upload audio file using an HTTP adapter

    ‏2012-11-14T05:30:29Z  
    Can you share a link to Google's Voice Recognition Service public API? What have you tried so far?

    I don't think you can send files to Worklight Adapters. You can however just record the audio, base64 encode it, send it to the adapter that way and have the server base64 decode it to play it.

    You can also try Apache Cordova's File API (it's already built-in into Worklight):

    "The FileTransfer object provides a way to upload files to a remote server using an HTTP multi-part POST request."
    http://docs.phonegap.com/en/1.6.1/cordova_file_file.md.html#FileTransfer
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: How to upload audio file using an HTTP adapter

    ‏2012-11-21T04:28:29Z  
    Can you share a link to Google's Voice Recognition Service public API? What have you tried so far?

    I don't think you can send files to Worklight Adapters. You can however just record the audio, base64 encode it, send it to the adapter that way and have the server base64 decode it to play it.

    You can also try Apache Cordova's File API (it's already built-in into Worklight):

    "The FileTransfer object provides a way to upload files to a remote server using an HTTP multi-part POST request."
    http://docs.phonegap.com/en/1.6.1/cordova_file_file.md.html#FileTransfer
    Hi cnandreu,

    Thank you for your reply. I created a simple web app that is hosted on tomcat. The web app is able to send audio file to google voice server and get back with recognized words. Here is the tutorial on how to do it. http://www.smartjava.org/content/record-audio-using-webrtc-chrome-and-speech-recognition-websockets

    Now I want to send my audio file from android to my tomcat server via Worklight adapter. I'm interested in your solution on encoding the file to base64. But I can't find any worklight APIs or library that can encode it. Can you point me to a right direction?

    Thanks :)

    Ming
  • IdanAdar
    IdanAdar
    741 Posts

    Re: How to upload audio file using an HTTP adapter

    ‏2012-11-21T05:24:36Z  
    There is no Worklight API to do so. It is common practice.

    There are numerous resources on the web on how to achieve this encoding.
    Here is one from StackOverflow, perhaps it will be of assistance: http://stackoverflow.com/questions/6448865/base64-encode-audio-file-and-send-as-a-string-then-decode-the-string
    Idan Adar
    QA Engineer
    IBM Worklight Mobile Platform
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: How to upload audio file using an HTTP adapter

    ‏2012-11-23T18:21:33Z  
    • IdanAdar
    • ‏2012-11-21T05:24:36Z
    There is no Worklight API to do so. It is common practice.

    There are numerous resources on the web on how to achieve this encoding.
    Here is one from StackOverflow, perhaps it will be of assistance: http://stackoverflow.com/questions/6448865/base64-encode-audio-file-and-send-as-a-string-then-decode-the-string
    Idan Adar
    QA Engineer
    IBM Worklight Mobile Platform
    Thanks Idan, I'll look into it. :)