fasttext.js icon indicating copy to clipboard operation
fasttext.js copied to clipboard

Using in the browser with WASM

Open Uzay-G opened this issue 4 years ago • 2 comments

Are the uploaded binaries for WASM usable in the browser? I tried following https://fasttext.cc/docs/en/webassembly-module.html#build-a-webpage-that-uses-fasttext to load fasttext using the provided binaries but I got import errors:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
</head>
<body>
    <script type="module">
        import {FastText, addOnPostRun} from "./fasttext.js";

        addOnPostRun(() => {
            let ft = new FastText();
            console.log(ft);
        });

    </script>
</body>
</html>

Uncaught SyntaxError: import not found: addOnPostRun in the browser.

Uzay-G avatar Nov 15 '21 08:11 Uzay-G

@Uzay-G correct I will provide a modified WASM module for browser based inference.

loretoparisi avatar May 12 '22 19:05 loretoparisi

Was actually looking for something to do language identification client side, bit sad this does work even though it seems it could.

wonderwhy-er avatar Jul 07 '23 14:07 wonderwhy-er