I created a Google Cloud Speech v2 recognizer via the front end of the web google cloud console. The Recognizer service is located in europe-west4, because I need the chirp model.
The problem comes when i try to get the recognizer via the Node.js client library.
我通过web google cloud console的前端创建了一个Google Cloud Speech v2识别器。Recognizer服务位于europe-west 4,因为我需要chirp模型。当我试图通过Node.js客户端库获取识别器时,问题就出现了。
client.getRecognizer({ name: `projects/${project}/locations/europe-west4/recognizers/my-first-chirp` })
The error is:
客户端.getRecognizer({名称:`projects/${project}/locations/europe-west4/recognizers/my-first-chirp`})错误为:
Google speech v2: 'Expected resource location to be global, but found europe-west4 in resource name.',
Google Speech v2:‘预期资源位置为全球,但在资源名称中发现了Europe-West4。’,
When i try to create a different recognizer in europe-west4 i get the same error, but when creating in "global" location there is no problem. The issue is that the model and language I need are not supported in "global".
当我尝试在Europe-West4中创建一个不同的识别器时,我得到了相同的错误,但在“global”位置创建时没有问题。问题是我所需要的模型和语言在“全球”中不受支持。
When I tried to find my recognizer in "global" with .getRecognizer
I got an error sayign there isn't such recognizer (as expected, because it is not in global).
当我试图用.getRecognizer在“global”中查找我的识别器时,我得到了一个错误,告诉我没有这样的识别器(不出所料,因为它不在全局中)。
I there a way to use google's node library with europe-west4?
有没有办法将Google的节点库与Europe-West4一起使用?
更多回答
优秀答案推荐
When creating the client you need to set the region in the URL:
创建客户端时,需要在URL中设置地域:
For Javascript/Typescript:
对于脚本/打字脚本:
this.client = new v2.SpeechClient({
apiEndpoint: `europe-west4-speech.googleapis.com`,
});
For Python
对于Python
client_options_var = client_options.ClientOptions(
api_endpoint="europe-west4-speech.googleapis.com"
)
client = SpeechClient(client_options=client_options_var)
Beware the "-speech" part region + "-speech.googleapis.com"
注意“-Speech”Part Region+“-Speech.googleapis.com”
更多回答
Thank you, this worked! A little after I posted the question i saw in the library and the documentation mentions of passing the apiEndpoint argument in the constructor and tried it like this: const client = new v2.SpeechClient({ apiEndpoint: 'europe-west4' })
This resultet in no error, but also the program freezes on awaiting of the .batchRecognize() promise.
谢谢,这招奏效了!在我发布了我在库中看到的问题和文档中提到的在构造函数中传递apiEndpoint参数并尝试这样做后不久:const client=new v2.SpeechClient({apiEndpoint:‘Europe-West4’})这个结果没有错误,但程序在等待.BatchRecognize()承诺时也会冻结。
我是一名优秀的程序员,十分优秀!