Playing input stream audio in j2me

want to make a text-to-speech synthesizer for mobile phones.
for that i am using FreeTTS (text-to-speech synthesizer written in java)
so i have made a client-server model where i have a midp client which is sending text to the FreeTTS acting as a server.... for this i am using socket...
so basically -- client is sending text to server -- server processes the text and sends the audio stream back to client
the problem is i dont know how to play the audio stream received on client side
i tried to copy it in a buffer but its not working..
do i need to save the file in some format before playing it?
or can the player play the audio stream directly?
this is how i am copying the contents in the buffer
try
InputStream is = socketConnection.openInputStream();
byte[] buff = new byte[1024];
int bytesIn = is.read(buff, 0, 1024);
ByteArrayInputStream bis = new ByteArrayInputStream(buff);
player = Manager.createPlayer(bis, "audio/x-wav" );
player.start();
but it gives an error saying
javax.microedition.media.MediaException: Malformed wave media
i tried to display the contents of bis on console it reads
java.io.ByteArrayInputStream@d590dbc
i tried the same with the Free TTS client and got the same output.
so i think client socket is even receiving the audio stream properly...however, im not sure.
is the whole client-server using socket idea correct?
if yes, please tell me how to play this audio stream in j2me (the client)
if it is wrong then please tell me a correct way to do this.
can the input stream be stored as a WAV file and then played? if yes, then how can i store it as a WAV file? Can this be achieved by appending a WAV header?

I once tried the similar thing, I ended up buffer all the content locally (from bluetooth), then play the wave file.
Maybe someone else has better idea.

Similar Messages

  • Using CAN bus to transport and play the stream audio data

    hello,
    Just want to build a PC-Based control network using CAN bus (Ethernet not considered).The system is separated two parts , one is the front unit(FU), and the other is the centeral unit(CU). FU performs dialing-up number to the CU , and play the stream audio media data come from CU, CU monitor the telephone call activated from FU's user , send rm or mp3 data to the FU . I'd like to know if CAN bus could realize this function? if it can , which hardware must be supplied ? Is there any suggestion that not use PBX to realize the voice (telphone) communication ? Please give an solution , your advise is greatly appreciated . Thanks.
    David

    Hi David,
    the CAN protocol essentially just gives you the ability to transfer (broadcast) up to eight data bytes across the network at a maximum data rate of 1 Mbit/s.
    There are so-called higher level (or layer) protocols that further specify the data exchange between a data producer can the consumer (DeviceNet, CANopen, etc.).
    If your application is not tied to any of those protocols, that means you have the freedom to design all (CAN) nodes of your network, you can implement your own protocol based on the eight data bytes and the arbitration ID CAN offers.
    For more information on the CAN protocol, take a look at appendix B of the NI-CAN Hardware and Software Manual, or visit the web site of CAN in Automation (CiA).
    For your particular application you would need a CAN port on both the FU and the CU (preferably high-speed physical layer) and a PCI interface CAN card for you development.
    -B2k

  • To play a stream audio file with external program...

    Hi, I get with stream a sound file and I have to play it using an external program like VLC, reading the file continuously of a buffer. How can I do it? Would I have to controll VLC commands? I have been reading about it, but I have no idea how to do it.
    Thanks.

    One way would be that you implement and run an RSTP server and give its URLs to VLC, RealPlayer or whatever proper RSTP client program.

  • Web Page Link Method To Play QT Streaming Audio?

    I need to insert a link in a web page that will play a 3 minute MP3 as it streams, not when it fully downloads.
    When the link on my page is clicked, I need the MP3 to play in the QT progress bar stop/start pop-up when the start pointer is clicked (or automatically when the page link is clicked but not when the page itself is opened as in Flash) that will still allow the original page to show, and not blank out the screen with a new white page that displays only the QT progress bar.
    I've seen these online. Can anyone direct me to the code or procedure to do this?
    Thanks - Gina

    Here is what I did...
    1. I created the video in Snapz Pro. Then I saved it to my desktop.
    2. Next, I uploaded the image file, which is a .mov file to my web site. I put mine in a folder called img.
    3. Now this is the best part, go to this web site:
    http://cit.ucsf.edu/embedmedia/step2_qtv2.php?mediatype=QuickTime
    4. I selected Web Server and then went to the next screen. On the next screen, add the web server name and the file path. I am a newbie so I made the mistake of adding the entire file path. You only need to add the info. after the web name. Example:
    My web server is: http://www.robenmariesmith.com
    My file path is: img/tutorials/PSActionsTutorial.mov
    Select the pixel image size for your largest image for width and height.
    Make the other selections that it requests and click Submit.
    5. On the next screen you can actually test your media. If all is working, copy and paste the code into your web site.
    Let me know if you need any more help and I will help if I can!
    Cheers,
    RM

  • Recording and Playing back Streaming Audio and Video

    Hi Folks...
    I posted this in another forum too. I have this sample code from the e-book: "Learning Flash Media Server 3". The purpose of the code is to create a FLV. The code is not running as it should. When I click on the 'record' button, the label is to change to 'recording', that dosen't seem to happen and also when I click on the 'Stop Record' button, I get the following error:
    "TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at MinRecord/stopRecord()"
    I have my suspicion on a certain section of the code as the possible culprit, but I am not sure how to rectify it, I will post the entire code here so you guys can have a look.
    package
          import fl.controls.Button;
          import fl.controls.TextInput;
          import flash.display.Sprite;
          import flash.net.NetConnection;
          import flash.net.NetStream;
          import flash.events.NetStatusEvent;
          import flash.events.MouseEvent;
          import flash.events.Event;
          //import flash.net.ObjectEncoding;
          import flash.media.Camera;
          import flash.media.Microphone;
          import flash.media.Video;
          public class MinRecord extends Sprite
           private var nc:NetConnection;
           private var ns:NetStream;
           private var rtmpNow:String;
           private var msg:Boolean;
           private var cam:Camera;
           private var mic:Microphone;
           private var vid1:Video;
           private var recordBtn:Button;
           private var stopBtn:Button;
           private var textInput:TextInput;
           //Constructor
           function MinRecord ()
           //NetConnection.defaultObjectEncoding = flash.net.ObjectEncoding.AMF0;
           nc=new NetConnection();
           nc.addEventListener (NetStatusEvent.NET_STATUS,checkConnect);
           rtmpNow="rtmp://192.168.0.11/vid2/recordings";
           //rtmpNow="rtmp:/vid2";
           nc.connect (rtmpNow);
           addMedia ();
           addUI ();
           recordBtn.addEventListener (MouseEvent.CLICK,startRecord);
           stopBtn.addEventListener (MouseEvent.CLICK,stopRecord);
         private function addMedia ():void
           cam=Camera.getCamera();
           cam.setMode (240,180,24);
           cam.setQuality (0,90);
           mic=Microphone.getMicrophone();
           vid1=new Video(cam.width,cam.height);
           vid1.attachCamera (cam);
           addChild (vid1);
           vid1.x=100;
           vid1.y=50;
           private function addUI ():void
           recordBtn=new Button();
           recordBtn.label="Record";
           recordBtn.x=100;
           recordBtn.y=50+(cam.height) +5;
           recordBtn.width=70;
           addChild (recordBtn);
           stopBtn=new Button();
           stopBtn.label="Stop Record";
           stopBtn.x=recordBtn.x+85;
           stopBtn.y=recordBtn.y;
           stopBtn.width=75;
           addChild (stopBtn);
           textInput=new TextInput();
           textInput.x=recordBtn.x;
           textInput.y=recordBtn.y + 30;
           addChild (textInput);
           private function checkConnect (e:NetStatusEvent):void
                msg=(e.info.code=="NetConnection.Connect.Success");
                 if (msg)
                  ns = new NetStream(nc);
           private function startRecord (e:Event):void
                 if (ns)
                       recordBtn.label="Recording";
                       ns.attachAudio (mic);
                       ns.attachCamera (cam);
                       ns.publish (textInput.text,"record");
           private function stopRecord (e:Event):void
                 recordBtn.label="Record";
                 ns.close ();
    My deduction is that the 'if' statement in the 'startRecord' function is not resolving to 'true' and hence the label is not changing to 'Recording'. Also I feel that the assingment to the variable 'ns' of type NetStream is not being done and hence in the function 'stopRecord' I get the above mentioned error message when I click on the stop button. How do I rectify these problems?

    Hi Amit,
    Thanks for the message, I had acutually realised late last evening that changing this:
    rtmpNow="rtmp://192.168.0.11/vid2/recordings"
    to this:
    rtmpNow="rtmp:/vid2"
    which is what you have also recomended solves one of the problems which is that of the startRecord function, as my server is running on my own local machine. However when I click on stop record, I am getting the following error:
    "Error #2044: Unhandled NetStatusEvent:. level=error, code=NetStream.Publish.BadName
    at MinRecord/checkConnect()"
    I am trying to figure this one out...if you have any clues, let me know. Thanks.

  • Play Streaming Audio

    I'm busy designing an app to play audio from a link. The audio is being streamed by a Shoutcast server. The link I have been given is 'http://live.rmr.ru.ac.za'. I've got the following code so far:
        // Read sampled audio data from the specified URL and play it
        private void streamSampledAudio(URL url)
            throws IOException, UnsupportedAudioFileException,
                   LineUnavailableException
            ain = null;  // We read audio data from here
            SourceDataLine line = null;   // And write it here.
            try {
                // Get an audio input stream from the URL
                ain=AudioSystem.getAudioInputStream(url);
                // Get information about the format of the stream
                AudioFormat format = ain.getFormat( );
                DataLine.Info info=new DataLine.Info(SourceDataLine.class,format);
                // If the format is not supported directly (i.e. if it is not PCM
                // encoded), then try to transcode it to PCM.
                if (!AudioSystem.isLineSupported(info)) {
                    // This is the PCM format we want to transcode to.
                    // The parameters here are audio format details that you
                    // shouldn't need to understand for casual use.
                    AudioFormat pcm =
                        new AudioFormat(format.getSampleRate( ), 16,
                                        format.getChannels( ), true, false);
                    // Get a wrapper stream around the input stream that does the
                    // transcoding for us.
                    ain = AudioSystem.getAudioInputStream(pcm, ain);
                    // Update the format and info variables for the transcoded data
                    format = ain.getFormat( );
                    info = new DataLine.Info(SourceDataLine.class, format);
                // Open the line through which we'll play the streaming audio.
                line = (SourceDataLine) AudioSystem.getLine(info);
                line.open(format); 
                // Allocate a buffer for reading from the input stream and writing
                // to the line.  Make it large enough to hold 4k audio frames.
                // Note that the SourceDataLine also has its own internal buffer.
                int framesize = format.getFrameSize( );
                byte[] buffer = new byte[4 * 1024 * framesize]; // the buffer
                int numbytes = 0;                               // how many bytes
                // We haven't started the line yet.
                boolean started = false;
                for(;;) {  // We'll exit the loop when we reach the end of stream
                    // First, read some bytes from the input stream.
                    int bytesread=ain.read(buffer,numbytes,buffer.length-numbytes);
                    // If there were no more bytes to read, we're done.
                    if (bytesread == -1) break;
                    numbytes += bytesread;
                    // Now that we've got some audio data to write to the line,
                    // start the line, so it will play that data as we write it.
                    if (!started) {
                        line.start( );
                        started = true;
                    // We must write bytes to the line in an integer multiple of
                    // the framesize.  So figure out how many bytes we'll write.
                    int bytestowrite = (numbytes/framesize)*framesize;
                    // Now write the bytes. The line will buffer them and play
                    // them. This call will block until all bytes are written.
                    line.write(buffer, 0, bytestowrite);
                    // If we didn't have an integer multiple of the frame size,
                    // then copy the remaining bytes to the start of the buffer.
                    int remaining = numbytes - bytestowrite;
                    if (remaining == 0)
                        System.arraycopy(buffer,bytestowrite,buffer,0,remaining);
                    numbytes = remaining;
                // Now block until all buffered sound finishes playing.
                line.drain( );
            finally { // Always relinquish the resources we use
                if (line != null) line.close( );
                if (ain != null) ain.close( );
        }Although I get an UnsupportedAudioFileException when using the link above.
    Please can someone point me in the right direction on how to play streaming audio?

    Please can I refer you to this thread.
    I'm struggling like you can't believe to do something which I thought would be quite simple.

  • Palm Pre - Here is how to create a web bookmark to launch a streaming audio site

    Once you have a URL that you have confirmed as working with the Pre to play streaming audio, unfortunately you can't create a bookmark when playing the streaming audio.  Here is a way you can create a bookmark to easily launch the site again to play the streaming audio:
    My example is for WHYY the PBS station in Philadelphia.  
    You can either create a new bookmark or use an existing one you don't use.  If you create a new bookmark you can set an icon you want to use.
    Use this process if you are creating a new bookmark.
    1a.    I entered the URL for WHYY, http://www.whyy.org, so I could create an icon with the visual for WHYY.  This step is not necessary and doesn't need to be related to the streaming audio content, it just allowed me to get the icon I wanted.
    1b.  With the WHYY site loaded I choose Menu>Add Bookmark
    1c.  I touched on the icon at the top of the window and adjusted the boundaries to just include the WHYY logo
    2.  I then touched in the URL line and changed the URL to http://207.245.67.204/listen.pls
    3.  I then touched the "Add Bookmark" button
    Use this process if you are using an existing bookmark that you want to recycle.  This bookmark will not be usable in its old form again.
    1a.  Within a web card tap Menu>Bookmarks to display the existing bookmarks.
    1b.  Find the bookmark you want to use and tap the information button, "i", at the right
    2.  Then tap in the URL line and change the URL to http://207.245.67.204/listen.pls
    3.  Then touch the "Add Bookmark" button 
    That's it.  You can now choose "Web" from the Launcher and touch the new bookmark and the streaming audio will launch. 
    Post relates to: Pre p100eww (Sprint)
    Post relates to: Pre p100eww (Sprint)
    Post relates to: Pre p100eww (Sprint)

    I had the same problem and found this article very useful.  It's clear, concise, and thorough.  I wish all step-by-step how-to documents were that readable!
    Thank you for posting,

  • Resume streaming audio by using MPMoviePlayerViewController after phone call is ended

    Hello,
    I am implementing an universal app. In which I used MPMoviePlayerViewController for playing streaming audio and its working fine. But when there is call during playing the streaming audio it stops. I also posted a question on Stack Overflow but no output (http://stackoverflow.com/questions/16333501/resume-mpmovieplayerviewcontroller-a fter-ending-phone-call/16333616?noredirect=1#comment23431276_16333616). How can I resume streaming audio after call is ended. Is there any way so that I can achieve this? Please help me out.

    See:
    iOS: Troubleshooting applications purchased from the App Store
    Contact the developer/go to their support site
    Restore from backup. See:
    iOS: How to back up
    Restore to factory settings/new iPod
    BTW this is the iPOd touch forum

  • HT204387 Can we play streaming audio from one device to other  device using A2DP profile ?

    Hi,
    Can we play streaming audio over two paired device .Please provide help us.
    Thanks
    Santosh

    If the other end supports the following
    http://support.apple.com/kb/HT3647
    you can plug an A2DP receiver into any speakers etc via the aux input
    and play music  from an iPod/iPad/iPhone

  • I recently purchased an Onkyo stereo receiver with a wireless USB adapter, UWF-1, and want to stream audio from my MacBook Pro through my stereo system. The receiver tells me it is connected to my wireless LAN, but I cannot get music to play?

    New to the community here, thanks for your patience.  I recently purchased an Onkyo TX-8050 Network Stereo Receiver with the UWF-1 USB adapter with the intent to stream audio from my MacBook Pro to the stereo. I have gone through the setup instructions for the adapter and the receiver gives me a message saying that it is connected to the password protected network, but that is as far as I can get.
    I have gone into iTunes and clicked on the "Open Stream" option, but I just get a pop up box labeled "URL" that is empty. I have Home Sharing turned on and File Sharing turned on, but I am not seeing the receiver in my Finder window or as a iTunes device.
    I would appreciate any and all advice and assistance.
    Thanks so much.
    Dan

    So I have been searching the iStore for Airplay and I find lots of information about what it is, but nothing about how much it costs, how/where to buy it, etc.?
    Fortunately, AirPlay does not cost anything as it is a streaming protocol used by Apple. Currently, the AirPort Express and Apple TV are AirPlay-ready. A number of other companies, like JBL, iHome, Denon and Klipsch are also rumored to be working on AirPlay versions of their products.
    Your other option would be to get an AirPort Express and connect it to your Onkyo analog or optical digital audio input and stream from iTunes that way. I currently do this with my 10+ year old Harmon Kardon HT receiver.

  • I want to be able to use airplay to stream audio to another iOS device, and then use that audio stream to be used when recording video instead of the built in microphone / microphone input. Is this possible?

    I want to be able to use airplay to stream audio to another iOS device, and then use that audio stream to be used when recording video instead of the built in microphone / microphone input. Is this possible?

    A third-party app probably cannot obtain a stream from another app. To the best of my knowledge, such a capability is not provided in the software development kit, apps being "sandboxed" from each other and so allowed to communicate only in very specific and limited ways.
    I'm not completely sure what you mean by "limitations on video capture". An iPhone, to the best of my knowledge, can natively record video only through it's built-in camera, and audio while doing video recording only through the built-in microphone or mic/headphone jack. There might be a video recording app that would allow audio input from an external device connected to the dock connector, but I'm not sure.
    Regards.

  • Streaming audio from my IPAD to my Apple TV from Rhapsody application.  when Apple TV go into Screen Saver mode, about 5 minutes after that it stops playing the Audio Stream and goes into Sleep mode.

    I am Streaming audio from my IPAD to my Apple TV from Rhapsody application.  when Apple TV go into Screen Saver mode, about 5 minutes after that it stops playing the Audio Stream and goes into Sleep mode.  I am using the Optical Out from the Apple TV to my receiver, the Apple TV is hard Wired to the Network, the IPAD is Wirelessly attached to the network (it continues to play the Audio Stream).  When the Apple TV is turned back on it resumes playing once I manual select it for output from the IPAD.  All device are on current releases of software.  I have no Video hooked up to the Apple TV.  How do I correct this?

    Intermittent problems are often a result of interference. Interference can be caused by other networks in the neighbourhood or from household electrical items.
    You can download and install iStumbler (NetStumbler for windows users) to help you see which channels are used by neighbouring networks so that you can avoid them, but iStumbler will not see household items.
    Refer to your router manual for instructions on changing your wifi channel or adjusting your multicast rate.
    There are other types of problems that can affect networks, but this is by far the most common, hence worth mentioning first. Networks that have inherent issues can be seen to work differently with different versions of the same software. You might also try moving the Apple TV away from other electrical equipment.

  • Bug: OS 4.5 Media Player does not allow BB screen to shut off when playing streaming audio

    I updated my Verizon Pearl 8130 to OS 4.5.  Now, when streaming audio from a station such as "Groove Salad" at http://www.somafm.com, the screen does not shut off but stays on indefinitely, wasting precious battery power.  OS 4.3 Media Player did allow the screen to turn off when streaming audio.
    - Bill

    I have a similar issue since upgrading to to 4.5 with my vzw 8130.   with 4.3 I was able to stream audio and then have it run in the background to read messages or address book for example all the while the audio was still playing.   Now once I get the audio streaming and back out to the main menu the media player quits.

  • Droid Razr Bug.  Won't play streaming audio from websites.

    My Droid Razr won't play streamed audio from a website and won't play .wav files attached to e-mails.  That's annoying.  
    Motorola tech support said problem will be fixed upon next upgrade of Android OS.  
    My phone is currently running Android OS 2.3.5.  
    Does anyone now of a quicker fix?
    Does anyone know when an OS upgrade will be available for the Droid Razr?
    Thx!

    i got the same issue on my ipod. i figured the whole idea of converting the format would solve the issue. never really found out how to solve it. i'll be watching this post to see if anyone has a solve for this issue.

  • Streaming Audio/Video Won't Play!

    Ok, I've had this dilemma for quite a while and I notice that it happens in every browser I use on my iBook. I want to listen to some streaming audio or watch streaming video and everytime it attempts to load I get a pop up saying "Cannot play back the file. The file format is invalid" This just happens usually when the streaming is Windows Media..is my Windows Media player not functioning correctly? What's going on? Any help would be appreciated. THANK YOU!

    From a Microsoft Bulletin:
    Cannot play back file. The file format is invalid.
    In some cases, you might be able to play the file in Microsoft Windows Media Player on a Microsoft Windows-based computer, but not on a Macintosh. This occurs because Windows Media Player for Mac is parses .asx files more strictly.
    This issue may occur if the .asx file contains an error, or if there is an error in the HTML coding of a Web page that contains an embedded Windows Media file.
    To resolve this issue, test to determine if Window Media Player can play other .asx files. If it can, contact the owner of the Web site to have the owner troubleshoot the .asx file.

Maybe you are looking for

  • How to create an EIT in Oracle apps with custom table?

    Hi, I have a custom table in APPS schema where training information is loaded everyday by running a control file. I've to pick the training end date and status of 5 particular trainings and create an EIT. When I try to create an EIT which is basicall

  • OBIEE BI Answers: Query filter on USER GROUP

    Hi, I have following problem. In Administration Tool i've defined a catalogue and I have associated to it a User Group "Ter Group". Then I have attached to this group a user with credentials: Username="Ter User" Password:"Ter". So in Answers i log in

  • Transaction codes from end user point of view

    hi all, I am expecting end user transaction codes of warehouse management. I am familiar with materials management but looking to learn WM. regards, nitin patil

  • Having trouble Compiling using Textpad editor???

    Hi, I Knew to java as well as computers and I need help? I downloaded the java kit and was using textpad as a text editor and every time i tried to compile it said it couldn't find my file, even though I just finished typing it??? Even when I to run

  • IMovie fails to create iDVD project

    After completing my iMovie project, clicking Create iDVD Project, Dialog box says launching iDVD, wait; but nothing happens after waiting hours!