const translator = await Translator.create({ sourceLanguage: 'en', targetLanguage: 'fr', });
await translator.translate('Where is the next bus stop, please?');
const translator = await Translator.create({ sourceLanguage: 'en', targetLanguage: 'fr', });
await translator.translate('Where is the next bus stop, please?');
That said, the "simple way around the paid API" problem is something Google has to deal with anyway, because there are a bunch of ways to use Google Translate without paying for it (e.g., the translate.google.com web UI, or the non-JavaScript-exposed "Translate to [language]" feature built into Chrome), and any action that can be taken by a human can in principle also be taken by a script. The only thing to do about it is use secret-sauce server-side abuse detection to block as much of this activity as they can; they can't get all of it but they can get enough to push enough people onto the paid API that the economics pencil out.
(Answered my own question): Doesn't look like it requires the user's permission. Upon first use, the model will start downloading. The user has to wait for the download to finish before the API will work. That could take hours for 22gb.
I presume this can't work on mobile?
https://developer.mozilla.org/en-US/docs/Web/API/Translator_...
It runs very slow. Test case that run translation for text in 3k chars multiple times, takes about 30 seconds for google translator, but more than 10 minutes for `nllb-200-distilled-600M`.
Text sample: https://github.com/translate-tools/core/pull/112/files#diff-...
My tests runs on nodejs, it looks in browser it have no chance for real world use