I am trying to access speech api using following url and always getting 403(Forbidden) Error, Invalid Key.
我试图使用以下网址访问语音api并始终获得403(禁止)错误,无效密钥。
https://www.google.com/speech-api/v2/recognize?output=json&lang=en-us&key={MyKey}
I have tried with both Server Key and Browser key as shown on this Keys image.
我已尝试使用此密钥图像上显示的服务器密钥和浏览器密钥。
I am sending http request using .NET HTTP Client; Code snippet is given below:
我正在使用.NET HTTP Client发送http请求;代码段如下:
Stream stream = null;
StreamReader sr = null;
WebResponse response = null;
JSon.RecognizedItem result;
try
{
WebRequest request = WebRequest.Create(Constants.GoogleRequestString);
request.Method = "POST";
request.ContentType = "audio/x-flac; rate=" + sampleRate;
request.ContentLength = bytes.Length;
stream = request.GetRequestStream();
stream.Write(bytes, 0, bytes.Length);
stream.Close();
response = request.GetResponse();
stream = response.GetResponseStream();
if (stream == null)
{
throw new Exception("Can't get a response from server. Response stream is null.");
}
sr = new StreamReader(stream);
//Get response in JSON format
string respFromServer = sr.ReadToEnd();
var parsedResult = JSon.Parse(respFromServer);
result =
parsedResult.hypotheses.Where(d => d.confidence == parsedResult.hypotheses.Max(p => p.confidence)).FirstOrDefault();
}
finally
{
if (stream != null)
stream.Close();
if (sr != null)
sr.Close();
if (response != null)
response.Close();
}
return result == null ? "" : result.utterance;
Can anybody please help me to identify the problem here.
有人可以帮我在这里找出问题所在。
Thanks, Ab.
1 个解决方案
#1
0
For that API endpoint, usage quota is no longer offered. And, apparently, it was an endpoint specific for community developers for the Chromium project.
对于该API端点,不再提供使用配额。而且,显然,它是针对Chromium项目的社区开发人员的特定端点。
Google's Speech API is the Cloud Speech API .
Google的Speech API是Cloud Speech API。
The keys you are referencing appear to be set up in your Google Cloud Project (GCP). GCP, implicitly those keys, can be linked to the Cloud Speech API, as pointed out here, not the https://www.google.com/speech-api/v2/ one.
您引用的密钥似乎是在您的Google云端项目(GCP)中设置的。如这里所指出的,GCP(隐含地是那些密钥)可以链接到Cloud Speech API,而不是https://www.google.com/speech-api/v2/。
#1
0
For that API endpoint, usage quota is no longer offered. And, apparently, it was an endpoint specific for community developers for the Chromium project.
对于该API端点,不再提供使用配额。而且,显然,它是针对Chromium项目的社区开发人员的特定端点。
Google's Speech API is the Cloud Speech API .
Google的Speech API是Cloud Speech API。
The keys you are referencing appear to be set up in your Google Cloud Project (GCP). GCP, implicitly those keys, can be linked to the Cloud Speech API, as pointed out here, not the https://www.google.com/speech-api/v2/ one.
您引用的密钥似乎是在您的Google云端项目(GCP)中设置的。如这里所指出的,GCP(隐含地是那些密钥)可以链接到Cloud Speech API,而不是https://www.google.com/speech-api/v2/。