我通过网络谷歌云控制台的前端创建了一个谷歌云语音v2识别器。识别器服务位于 europe-west4 中,因为我需要 chirp 模型。 当我尝试通过 Node.js 客户端库获取识别器时,问题就出现了。
client.getRecognizer({ name: `projects/${project}/locations/europe-west4/recognizers/my-first-chirp` })
错误是:
Google 语音 v2:“预期资源位置为全局,但在资源名称中发现 europe-west4。”,
当我尝试在 europe-west4 中创建不同的识别器时,我收到相同的错误,但在“global”位置创建时没有问题。问题是“global”不支持我需要的模型和语言。
当我尝试使用 .getRecognizer
在“global”中查找我的识别器时,我收到一条错误消息,说没有这样的识别器(正如预期的那样,因为它不是全局)。
我有办法将 google 的节点库与 europe-west4 一起使用吗?
最佳答案
创建客户端时需要在 URL 中设置区域:
对于 JavaScript/Typescript:
this.client = new v2.SpeechClient({
apiEndpoint: `europe-west4-speech.googleapis.com`,
});
对于Python
client_options_var = client_options.ClientOptions(
api_endpoint="europe-west4-speech.googleapis.com"
)
client = SpeechClient(client_options=client_options_var)
注意“-speech”部分region +“-speech.googleapis.com”
关于location - 谷歌语音 v2 : 'Expected resource location to be global, but found europe-west4 in resource name.' ,,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/77076285/