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 7036717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:27:27+00:00 2026-05-28T01:27:27+00:00

The following simple code tries to post a wave file to Google Speech2Text service,

  • 0

The following simple code tries to post a wave file to Google Speech2Text service, but always fails with either a “Gateway Timeout (504)” or general exception “The operation timed out”. Can anyone help please?

  public void ProcessWaveFile(string path)
    {
        HttpWebRequest request = 
             (HttpWebRequest)HttpWebRequest.Create(
                 "https://www.google.com/"+ 
                 "speech-api/v1/recognize?"+ 
                 "xjerr=1&client=speech2text&lang=en-US&maxresults=10");

        ServicePointManager.ServerCertificateValidationCallback += 
                     delegate { return true; };

        request.Timeout = 60000;
        request.Method = "POST";
        request.KeepAlive = true;           
        request.ContentType = "audio/wav";
        request.UserAgent = "speech2text";

        FileInfo fInfo = new FileInfo(path);
        long numBytes = fInfo.Length;
        byte[] data;

        using (FileStream fStream = new FileStream(
                                          path, 
                                          FileMode.Open, 
                                          FileAccess.Read))
        {
            data = new byte[fStream.Length];
            fStream.Read(data, 0, (int)fStream.Length);
            fStream.Close();
        }

        using (Stream wrStream = request.GetRequestStream())
            wrStream.Write(data, 0, data.Length);

        try
        {
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            var resp = response.GetResponseStream();

            if (resp != null)
            {
                StreamReader sr = new StreamReader(resp);
                MessageBox.Show(sr.ReadToEnd());

                resp.Close();
                resp.Dispose();
            }
        }
        catch (System.Exception ee)
        {
            MessageBox.Show(ee.Message);
        }           
    }

Many thanks.

Shujaat

  • 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-28T01:27:27+00:00Added an answer on May 28, 2026 at 1:27 am

    Your code works for me with the following change:

    Request.ContentType = "audio/x-flac; rate=8000";
    

    and the file that you provide needs to be in FLAC format.

    I recorded a small sample with Windows Sound Recorder which produces an WMA file. Then I used the VLC Player to convert the WMA file to FLAC (using the Convert options, make sure to output in RAW format, one channel and 8000 kbps)

    A good non c# reference with as well some extended api doc in the comments

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

Sidebar

Related Questions

i have the following simple code, but it doesn,t work <ul> <li id=one onmouseover=this.style.background-color='white';>
I have the following simple Java code: package testj; import java.util.*; public class Query<T>
I have got the following very simple code: function init() { var articleTabs =
My problem is a bit more complex than using the following simple JavaScript code:
I'm trying to compile the following simple DL library example code from Program-Library-HOWTO with
I have a simple DOM code like the following <div> <div> </div> </div> I
I want to code a simple form layout in flex. Something like the following:
The following code has a simple binding which binds the Text of the TextBlock
The following code executes a simple insert command. If it is called 2,000 times
The following code is a simple thread game, that switches between threads causing the

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.