我们可以使用 Nodejs 进行语言翻译吗

问题描述 投票:0回答:1

如果是,请提供一些链接,否则请告诉我原因

我已经下载了翻译模型,然后尝试使用库“@xenova/transformers”,它无法加载模型进行测试,因为我的模型扩展类似于 model.gguf

node.js huggingface-transformers language-translation
1个回答
0
投票

您可以使用 Node.js 中现有的“translatte”模块。这是与这个开源库相关的链接:

Node.js 翻译模块

一般步骤:

第一步:在终端中写入“npm install translatte”或“npm i translatte”。

第二步:您可以将translate()函数与try-catch资源一起使用,如下代码:

const wordToBeTranslated = "Hello Universe!";
translatte(wordToBeTranslated, { to: "fr" }).then(response => {
   console.log(`The French translation of the word ${wordToBeTranslated} is ${response.text}`);
}).catch((err) => {
   throw err;
});
© www.soinside.com 2019 - 2024. All rights reserved.