使用来自GoogleCloudPlatform\python-docs-samples-master\python-docs-samples-master\translate\cloud-client.的Python示例当我尝试使用翻译文本模型翻译时,我会得到错误信息。
python翻译-文本与模型es“你好吗奶奶”google.cloud.exceptions.BadRequest: 400个无效的google.cloud.exceptions.BadRequest有效负载收到。未知名称“模型”:无法绑定'nmt‘。在请求消息中找不到“模型”字段。(获取https://translation.googleapis.com/language/translate/v2?target=es&q=How+are+you+Grandma&model=nmt)
有人能指出我做错了什么吗?谢谢。
发布于 2017-02-18 15:59:04
我也遇到了这个问题。我通过将'model‘传递为null来解决这个问题。我正在使用PHP,但理论上它应该适用于Python。
$translation = $translate->translate($text, [
'target' => $target,
'source' => $source,
'model' => null
]);
发布于 2019-11-08 04:35:30
我确信这个问题已经解决了,但是我也面临着同样的问题,我意识到request.json没有被正确地指定。
通过查找当前链接:https://cloud.google.com/translate/docs/reference/rest/v3/projects.locations/translateText来修复您的请求JSON
另外,我犯了一个错误,就是在API版本上没有匹配JSON。
我使用JSON格式将v2转换API与v3 API结合使用。
https://stackoverflow.com/questions/41986516
复制相似问题