2

我正在尝试使用 C# 使用 Bing Speech Api,但 95% 的时间我从 API 获得以下响应:

Message=SendRequest: 收到非成功状态 :: Status Code: ServiceUnavailable; 原因: ; 内容:http://www.w3.org/1999/xhtml'>body { font-family:Arial; 左边距:40px;}img { 边框:0 无;}#content { margin-left: auto; margin-right: auto }#logo { margin-top: 30px; 宽度=120像素;height=34px }#message h2 { 字体大小:20px; 字体粗细:正常;颜色:#000000;边距:34px 0px 0px 0px }#message p { 字体大小:13px; 颜色:#000000;边距:7px 0px 0px 0px }#errorref { 字体大小:11px; 颜色:#737373;边距顶部:41px }必应

Bing 服务目前不可用

我们正在努力尽快恢复所有服务。
我们知道您想重新开始搜索。请稍后再回来查看。

参考 A:A1C0134338234D4AA480524F216CB616 参考 B:PAR02EDGE0112 参考 C:2018-09-27T17:12:16Z

我确实有一个有效的密钥,并且我已成功通过 API 进行身份验证,起初我认为服务器已关闭,但一周以来我得到了相同的响应,所以我认为还有其他问题。

任何见解将不胜感激。

编辑:我正在通过开源 C# 库(https://github.com/NateRickard/Xamarin.Cognitive.BingSpeech)与 api 进行通信。我使用的端点是库中的默认端点,“speech.platform.bing.com/speech/recognition”。

以下是通过 HTTP 发送的请求的概述:

{Method: POST, RequestUri: 'https://speech.platform.bing.com/speech/recognition/interactive/cognitiveservices/v1?language=fr-FR&format=simple&profanity=masked', Version: 1.1, Content: System.Net.Http.PushStreamContent, Headers:
{
  Transfer-Encoding: chunked
  Expect: 100-continue
  Accept: application/json
  Accept: text/xml
  Host: speech.platform.bing.com
  Ocp-Apim-Subscription-Key: {my subscription key}
  Content-Type: audio/wav
}}
4

1 回答 1

0

我不知道为什么,但是如果我使用以下标头(而不是您的标头),它对我来说适用于 python:

url = 'https://speech.platform.bing.com/speech/recognition/dictation/cognitiveservices/v1?language=en-US&format=detailed'

header = {
    'Accept': 'application/json',
    'Ocp-Apim-Subscription-Key': YOUR_API_KEY,
    'Content-type': 'audio/wav; codec=audio/pcm; samplerate=16000',
    'Authorization': 'Bearer {0}'.format(token)
}

r = requests.post(url, headers=header, data=audiodata)
于 2018-10-06T14:52:13.827 回答