artyom.js
artyom.js copied to clipboard
Artyom with express
Hi, I'm trying to use artyom in a express nods app. I added with the following command (inside the project folders)
npm install artyom.js
And I see it in node_modules. In app.js I add the following lines:
var artyom = require('artyom.js/build/artyom.js');
const jarvis = new Artyom();
but when I start the app I got the following error:
const jarvis = new Artyom();
ReferenceError: Artyom is not defined
Any idea why? Thanks 4b
Have you tried just require("artyom.js")
? It should work out of the box requiring only the name of the module.
of course but no chance, doesn't work with only artyom.js, is for that I have tried with full path. Others module works out of the box.
Any others idea?
Ah, the error is not the module, check the uppercase:
var Artyom = require('artyom.js');
const jarvis = new Artyom();
yes, I found this typo error me too. Thanks but it doesn't work anyway.... I got
const jarvis = new Artyom();
^
TypeError: Artyom is not a constructor
Has anyone solved this?
Are you running this in the browser?
Hello, I have the same issue :/ I want to use Artyom in a bot for Discord (made with node.js)
const Artyom = require("artyom.js");
const artyom = new Artyom();
const artyom = new Artyom(); TypeError: Artyom is not a constructor
Does someone know what it is or what to do ? Thanks
I ran into this issue recently in working with this after doing npm install on nodejs, and found that changing:
exports.default = Artyom;
to:
exports.Artyom = Artyom;
At the end of build/artyom.js allowed me to do the following:
var Artyom = require('./node_modules/artyom.js/build/artyom.js').Artyom; this.voice = new Artyom();
this being a class that assigns the new Artyom object to its voice member. I'm able to start it up, and now I'm just going through trying to get it to recognize any voice inputs (which may be a different issue than something inside Artyom, since I'm experimenting with node inside Electron right now).
If that issue has to do with Artyom, I'll update..
same problem with electron :/
$ electron .
App threw an error during load
TypeError: Artyom is not a constructor
at Object.<anonymous> (/Users/rodrigooler/proje
cts/friday/with-electron-app/main/index.js:7:16)
at Object.<anonymous> (/Users/rodrigooler/proje
cts/friday/with-electron-app/main/index.js:49:3)
at Module._compile (module.js:642:30)
at Object.Module._extensions..js (module.js:653
:10)
at Module.load (module.js:561:32)
at tryModuleLoad (module.js:504:12)
at Function.Module._load (module.js:496:3)
at loadApplicationPackage (/Users/rodrigooler/p
rojects/friday/with-electron-app/node_modules/elect
ron/dist/Electron.app/Contents/Resources/default_ap
p.asar/main.js:287:12)
at Object.<anonymous> (/Users/rodrigooler/proje
cts/friday/with-electron-app/node_modules/electron/
dist/Electron.app/Contents/Resources/default_app.as
ar/main.js:328:5)
at Object.<anonymous> (/Users/rodrigooler/proje
cts/friday/with-electron-app/node_modules/electron/
dist/Electron.app/Contents/Resources/default_app.as
ar/main.js:365:3)
Yeah, don't bother. Found that NWJS (and Electron, I believe) does not support voice recognition because Google pulled it from Chromium in order to get devs to use the cloud API. However, you can still do it through the browser, and what I wound up doing for my purposes was to pop a tab in Chrome with Artyom doing the voice recognition and an HTML "please don't close because XXX" blurb while routing the voice commands to NWJS via IPC. Works for now- would be nicer if Google put that bit back into Chromium instead of trying to force a cloud routing of voice data. But yeah, never got it to work on NodeJS as such.
@DigitalFlux
I ran into this issue recently in working with this after doing npm install on nodejs, and found that changing:
exports.default = Artyom;
to:
exports.Artyom = Artyom;
At the end of build/artyom.js allowed me to do the following:
var Artyom = require('./node_modules/artyom.js/build/artyom.js').Artyom; this.voice = new Artyom();
this being a class that assigns the new Artyom object to its voice member. I'm able to start it up, and now I'm just going through trying to get it to recognize any voice inputs (which may be a different issue than something inside Artyom, since I'm experimenting with node inside Electron right now).
If that issue has to do with Artyom, I'll update..
In case I just managed to make it work because of your comment above to adjust the export unfortunately it is not working in the current version. I was able to make parts work on electron but I need to solve the window problem. I'll put the solution here if I can. I have not gotten into the problem you said yet, but it can be an unfortunate problem.
Same here. I also tried the solution mentioned above about changing default export. following is the error i get : `(base) LT6564:node-server-tutorial amreen.rajmohmad$ node server.js /Users/amreen.rajmohmad/Documents/node-server-tutorial/node_modules/artyom.js/build/artyom.js:59 if (window.hasOwnProperty('speechSynthesis')) { ^
ReferenceError: window is not defined
at new Artyom (/Users/amreen.rajmohmad/Documents/node-server-tutorial/node_modules/artyom.js/build/artyom.js:59:13)
at Object.
Okay, So how i resolved this is :
const Artyom = require('artyom.js').default;
since I was facing a windows error as I mentioned in my previous comment
I saw there was already a PR addressing it.
https://github.com/sdkcarlos/artyom.js/pull/98/files
I replaced my Artyom.js file with these updated changes.
Then to make sure that node_modules use this changes : run following command from your package. it will create patches folder.
npx patch-package <package name>
and add the following flag in your package.json so that on npm install this patch is applied again.
"postinstall": "npx patch-package"
https://stackoverflow.com/questions/13300137/how-to-edit-a-node-module-installed-via-npm