Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I am trying to create an interface with an external server, and don't know where to start. I would need to take audio as input to my computer, and send it to the remote server as a chunked HTTP request. The API that I'm trying to connect to is described here p1-5

http://dragonmobile.nuancemobiledeveloper.com/public/Help/HttpInterface/HTTP_Services_for_NDEV_v1.2_Silver_Version.pdf

I have never worked with audio programmatically, so don't know what would be the most straightforward way to go about this? Are there solutions that exist out there that already do this?

I've come across references to Shoutcast, VLC, Icecast, FFMPeg, Darkice, but I don't know if those are appropriate for what I'm trying to accomplish or not.

share|improve this question

3 Answers 3

IceCast, ShoutCast and the like aren't going to help you except in that they employ the ffmpeg library to do their encoding and stream utility functions.

You'll need to download the ffmpeg library it is written in c but has wrappers written most languages if you are not comfortable writing in native c code. You will also want to check out the ffmpeg develper docs.

Do not, I mean it DO NOT attempt to do the encoding yourself unless you already are extremely comfortable with this procedure or have a LOT of time to spend on this. Use the standard PCM encoding that is offered by ffmpeg.

share|improve this answer

It looks like you need to encode your audio as 8KHz 16-bit PCM, then split it into 260ms chunks and send those one at a time to the service. The actual encoding method for the data isn't specified, I'd start with converting the samples to network byte order then stick the octets into the request as UTF-8 and see if that works.

share|improve this answer
1  
Why, why, why would somebody do this as HTTP? Can anybody come up with a reason that doesn't give me massive heartburn? –  jamesson Mar 17 '13 at 3:54
    
The reasons you might stream audio over HTTP are similar to the reasons for protocols like HLS that stream video over HTTP. –  Rein Henrichs Apr 16 '13 at 1:27
    
If I was doing something as part of a medical application in the NHS (UK), I would do it over HTTP or HTTPS, simply because that way you know the ports will be unblocked over the network. Anything else, and you are creating 6 months of paperwork pain (and cost) –  Ptolemy Sep 23 '13 at 9:11

Try this code

public function download_data_chunk(){
    $get = $this->input->get();
    $type = base64_decode($get['t']);
    $filename = base64_decode($get['f']);
    $filename = str_replace('+',' ',$filename);
    $filename = str_replace('%28','(',$filename);
    $filename = str_replace('%29',')',$filename);
    $str = FCPATH;
    if(trim(strpos($str, "/"))!="") {
        $path_dir =$str.'assets/uploaded/products/';
    } else {
        $path_dir =$str.'assets\uploaded\products\\';
    }

    $file = $path_dir.$filename;
    $chk = file_exists($file);
    if($chk == 1){
        $filename = $file;
        $mimetype = array("application/octet-stream");
        header('Content-Type: '.$mimetype );
        header('Content-Disposition: attachment; filename="'.$mimetype.'"' );
        chunked_download($filename);
    } else {
        echo $path_dir;
    }
}
share|improve this answer
    
how does this answer the question asked? –  gnat Sep 23 '13 at 9:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.