如何通过 POSTMAN 命中 Microsoft 语言检测 API

问题描述

我在本地运行语言检测认知服务 API(使用以下命令)。

docker run --rm -it -p 5003:5003 --memory 1g --cpus 1 mcr.microsoft.com/azure-cognitive-services/speechservices/language-detection Eula=accept Billing=https://.api.cognitive.microsoft.com/sts/v1.0/issuetoken ApiKey=*** HTTP_PROXY=********

enter image description here

问题:当我通过 Postman 时收到 404

enter image description here

注意:我的认知服务区域是西欧和定价层 F0

请告诉我测试本地运行认知 api 的正确方法

解决方法

尝试使用资源名称,然后重试。

enter image description here

错误的原因是:

您应该将 Content-TypeOcp-Apim-Subscription-Key 放在标题中。

enter image description here

我这边的照片。

enter image description here

enter image description here

enter image description here

,

@SanK,您是尝试进行语音语言检测还是 TextAnalytics 语言检测?由于这是两种不同的功能,请确保您的订阅注册了正确的功能。

语音语言检测 - 从语音中检测语言。 TextAnalytics 语言检测 - 从文本中检测语言。

,

本地运行

docker run --rm -it -p 5003:5003 --memory 1g --cpus 1 mcr.microsoft.com/azure-cognitive-services/speechservices/language-detection Eula=accept Billing=https://.api.cognitive.microsoft.com/sts/v1.0/issuetoken ApiKey=*** HTTP_PROXY=********

在您的情况下,您的 Billing 值不正确:您已设置 https://.api.cognitive.microsoft.com/sts/v1.0/issuetoken,但您应该使用在您的 Azure 资源概览页面上可见的端点 URI,请参阅下面的我的资源: Cognitive Resource Overview

这在官方文档中有很好的描述(参见here

消费

然后,与您的邮递员一起,您应该调用您的本地实例。在您的捕获中,您正在调用 Microsoft 端的 API (https://westeurope...)。您应该使用 http://localhost:5003/speech/languagedetection/cognitiveservices/v1 在您发布的 swagger 捕获中可见