evancohen / sonus

:speech_balloon: /so.nus/ STT (speech to text) for Node with offline hotword detection
MIT License
618 stars 79 forks source link

Uncaught Error for something really not sure about #98

Closed Sanjit1 closed 4 years ago

Sanjit1 commented 4 years ago

I cannot really make sense of this error

internal/modules/cjs/loader.js:630 Uncaught Error: Cannot find module 
'/home/pi/NodePractice/node_modules/snowboy/lib/node/binding/Release/electron-v6.0-linux-arm/snowboy.node'
Require stack:
- /home/pi/NodePractice/node_modules/snowboy/lib/node/index.js
- /home/pi/NodePractice/node_modules/sonus/index.js
- /home/pi/NodePractice/mainWindow.html
    at Module._resolveFilename (internal/modules/cjs/loader.js:627)
    at Function.Module._resolveFilename (node_modules/electron/dist/resources/electron.asar/common/reset-search-paths.js:41)
    at Function.Module._load (internal/modules/cjs/loader.js:531)
    at Module.require (internal/modules/cjs/loader.js:685)
    at require (internal/modules/cjs/helpers.js:16)
    at Object.<anonymous> (node_modules/snowboy/lib/node/index.js:8)
    at Object.<anonymous> (node_modules/snowboy/lib/node/index.js:141)
    at Module._compile (internal/modules/cjs/loader.js:786)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:798)
    at Module.load (internal/modules/cjs/loader.js:645)

Script in the html file:

const Sonus = require('sonus');
const hotwords = [{ file: ROOT_DIR + '/mirror.pmdl', hotword: 'SmartMirror' }];
const sonus = Sonus.init({ hotwords }, arecord);
Sonus.start(sonus);
sonus.on('hotword', (index, keyboard) => document.getElementById('par').innerHTML = document.getElementById('par').innerHTML + "<br>  Say");
sonus.on('final-result', console.log);

Running electron, on RPI 3

main js file:
const electron = require('electron');
const url = require('url');
const path = require('path');
const {app, BrowserWindow} = electron;

let mainWindow;

app.on('ready',function(){
mainWindow = new BrowserWindow({
        webPreferences: {
                nodeIntegration: true
            }});

mainWindow.webContents.openDevTools();

mainWindow.loadURL(url.format({
pathname: path.join(__dirname, 'mainWindow.html'),
protocol:'file:',
slashes: true

}));  

});
Sanjit1 commented 4 years ago

I feel like there is an error because of conflicting files. I'm not so sure

evancohen commented 4 years ago

It's because you're using Electron, check out #15. Also potentially useful: https://github.com/evancohen/sonus-electron-boilerplate

Closing this out because those links should fix your issue.