Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4617260
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:05:57+00:00 2026-05-22T02:05:57+00:00

Hi i need to play mp3 file from google’s texttospeech api at here .But

  • 0

Hi i need to play mp3 file from google’s texttospeech api at here .But i can not figure out how to do it, here is a code i tried but didnt work.

String url = "http://translate.google.com/translate_tts?tl=en&q="+URLEncoder.encode(home)+URLEncoder.encode(scores[0])+
        URLEncoder.encode(away)+URLEncoder.encode(scores[1]);

    player = new MediaPlayer();
    try {
        BufferedInputStream bis = new BufferedInputStream(new java.net.URL(url).openStream());
        FileOutputStream fos = new FileOutputStream("/sdcard/tts_google.mp3");
        BufferedOutputStream bos = new BufferedOutputStream(fos,1024);
        byte [] data = new byte[1024];

        int x=0;
        while((x=bis.read(data,0,1024))>=0){
            bos.write(data,0,x);               
        }
        player.reset();
        player.start();

    } catch (MalformedURLException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

This one gives error that

05-11 14:04:12.967: ERROR/MediaPlayer(20055): start called in state 1
05-11 14:04:12.967: ERROR/MediaPlayer(20055): error (-38, 0)
05-11 14:04:12.967: DEBUG/MediaPlayer(20055): start() out
05-11 14:04:12.997: ERROR/MediaPlayer(20055): Error (-38,0)

And here is the second code i tried

httpClient = new DefaultHttpClient();
    handler = new BasicResponseHandler();
    httpGet = new HttpGet(url);

    try {

        String response = httpClient.execute(httpGet,handler);
        Log.d("SCORODROID", response);

        File mp3File = File.createTempFile("tts_result",".mp3");
        FileOutputStream fos = new FileOutputStream(mp3File);
        fos.write(response.getBytes());

        FileInputStream fis = new FileInputStream(mp3File);
        player.setDataSource(fis.getFD());

        player.prepare();
        player.start();

    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

This one also gives error

05-11 14:05:40.687: ERROR/MediaPlayer(20132): Unable to to create media player
05-11 14:05:40.687: WARN/System.err(20132): java.io.IOException: setDataSourceFD failed.: status=0x80000000
05-11 14:05:40.687: WARN/System.err(20132):     at android.media.MediaPlayer.setDataSource(Native Method)
05-11 14:05:40.687: WARN/System.err(20132):     at android.media.MediaPlayer.setDataSource(MediaPlayer.java:891)
05-11 14:05:40.687: WARN/System.err(20132):     at com.scoredroid.android.LiveScoreFetcher.ttsGoogle(LiveScoreFetcher.java:80)
05-11 14:05:40.687: WARN/System.err(20132):     at com.scoredroid.android.SpeechInputActivity$GetMetadata.onPostExecute(SpeechInputActivity.java:151)
05-11 14:05:40.687: WARN/System.err(20132):     at com.scoredroid.android.SpeechInputActivity$GetMetadata.onPostExecute(SpeechInputActivity.java:1)
05-11 14:05:40.687: WARN/System.err(20132):     at android.os.AsyncTask.finish(AsyncTask.java:417)
05-11 14:05:40.687: WARN/System.err(20132):     at android.os.AsyncTask.access$300(AsyncTask.java:127)
05-11 14:05:40.687: WARN/System.err(20132):     at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
05-11 14:05:40.687: WARN/System.err(20132):     at android.os.Handler.dispatchMessage(Handler.java:99)
05-11 14:05:40.687: WARN/System.err(20132):     at android.os.Looper.loop(Looper.java:143)
05-11 14:05:40.687: WARN/System.err(20132):     at android.app.ActivityThread.main(ActivityThread.java:4196)
05-11 14:05:40.687: WARN/System.err(20132):     at java.lang.reflect.Method.invokeNative(Native Method)
05-11 14:05:40.687: WARN/System.err(20132):     at java.lang.reflect.Method.invoke(Method.java:507)
05-11 14:05:40.687: WARN/System.err(20132):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-11 14:05:40.687: WARN/System.err(20132):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)

None of the code samples worked by the way can you help me out with this ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T02:05:58+00:00Added an answer on May 22, 2026 at 2:05 am

    Are you sure you are getting an MP3 from there? Have you checked the reply? For example, using wget in the console gives me a 403 Error although it works in the browser on that URL. So probably Google is blocking such requests (i.e. not originating from a Browser). In case you want just to use TTS, try using the integrated TTS engine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to download a mp3 file from a server URL, and then play
I need to play a part of an MP3 file in my java code.
I need to be able to play a RealAudio (.RA) file from Xcode. If
I need to play a mp3 audio file when the user clicks on a
Guys i able to play audio file using Mediaplayer. But i need to play
I need to play some music from a posisition on the sdcard how can
I need to download a .mp3 or .m4a file from the server by using
I need to download an .mp3 audio file from a server to save in
I need to play audio file from remote server in my app. I could
I need to Play a MP3 File in Java code under Linux environment (

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.