npm 中文文档 npm 中文文档
指南
npmjs.com (opens new window)
指南
npmjs.com (opens new window)
  • 快速入门

    • npm 是什么?
    • npm 安装和更新
    • npm 防止权限错误
    • npm package.json 文件
    • npm 安装包
    • npm 更新包
    • npm 卸载包
    • npm 创建 Node.js 模块
    • npm 发布和更新包
    • npm 使用语义化版本
    • npm 使用 Dist-tags 标记包
    • npm 包和模块的了解
  • 命令行
  • 配置 npm

Update for Chrome 71


Due to abuse of users with the Speech Synthesis API (ADS, Fake system warnings), Google decided to remove the usage of the API in the browser when it's not triggered by an user gesture (click, touch etc.). This means that calling for example artyom.say("Hello") if it's not wrapped inside an user event won't work.

So on every page load, the user will need to click at least once time per page to allow the usage of the API in the website, otherwise the following exception will be raised: "[Deprecation] speechSynthesis.speak() without user activation is no longer allowed since M71, around December 2018. See https://www.chromestatus.com/feature/5687444770914304 for more details"

For more information, visit the bug or this entry in the forum. To bypass this error, the user will need to interact manually with the website at least once, for example with a click:

  1. ``` html
  2. <button id="btn">Allow Voice Synthesis</button>
  3. <script src="artyom.window.js"></script>
  4. <script>
  5.     var Jarvis = new Artyom();
  6.     // Needed user interaction at least once in the website to make
  7.     // it work automatically without user interaction later... thanks google .i.
  8.     document.getElementById("btn").addEventListener("click", function(){
  9.         Jarvis.say("Hello World !");
  10.     }, false);
  11. </script>
  12. ```

Table of Contents


About Artyom
Speech Recognition
Voice Synthesis

Installation
NPM
Bower

How to use
Basic usage
All you need to know about Artyom
Development
Building Artyom from source
Testing

Languages
Demonstrations
Thanks

About Artyom


Artyom.js is a robust and useful wrapper of the webkitSpeechRecognition and speechSynthesis APIs. Besides, artyom allows you to add dynamic commands to your web app (website).

Artyom is constantly updated with new gadgets and awesome features, so be sure to star and watch this repository to be aware of any update. The main features of Artyom are:

Speech Recognition


Quick recognition of voice commands.
Add commands easily.
Smart commands (usage of wildcards and regular expressions).
Create a dictation object to convert voice to text easily.
Simulate commands without microphone.
Execution keyword to execute a command immediately after the use of the keyword.
Pause and resume command recognition.
Artyom has available the soundex algorithm to increase the accuracy of the recognition of commands (disabled by default).
Use a remote command processor service instead of local processing with Javascript.
Works both in desktop browser and mobile device.

Voice Synthesis


Synthesize extreme huge blocks of text (+20K words according to the last test).
onStart and onEnd callbacks will be always executed independently of the text length.
Works both in desktop browser and mobile device.

Read the changelog to be informed about changes and additions in Artyom.js

Installation


NPM


  1. ``` batchfile
  2. npm install artyom.js
  3. ```

Bower


  1. ``` batchfile
  2. bower install artyom.js
  3. ```

Or just download a .zip package with the source code, minified file and commands examples : download .zip file

How to use


Artyom is totally written in TypeScript, but it's transpiled on every version to JavaScript. 2 files are built namely artyom.js (used with Bundlers like Webpack, Browserify etc.) and artyom.window.js (only for the web browser). As everyone seems to use a bundler nowadays, for  the module loader used is CommonJS:

  1. ``` js
  2. // Using the /build/artyom.js file
  3. import Artyom from './artyom.js';

  4. const Jarvis = new Artyom();

  5. Jarvis.say("Hello World !");
  6. ```

Alternatively, if you are of the old school and just want to use it with a script tag, you will need to use the artyom.window.js file instead:

  1. ``` html
  2. <script src="artyom.window.js"></script>
  3. <script>
  4.     var Jarvis = new Artyom();
  5.     Jarvis.say("Hello World !");
  6. </script>
  7. ```

The source code of artyom handles a single TypeScript file /source/artyom.ts.

Basic usage


Writing code with artyom is very simple:

  1. ``` js
  2. // With ES6,TypeScript etc
  3. import Artyom from './artyom.js';

  4. // Create a variable that stores your instance
  5. const artyom = new Artyom();

  6. // Or if you are using it in the browser
  7. // var artyom = new Artyom();// or `new window.Artyom()`

  8. // Add command (Short code artisan way)
  9. artyom.on(['Good morning','Good afternoon']).then((i) => {
  10.     switch (i) {
  11.         case 0:
  12.             artyom.say("Good morning, how are you?");
  13.         break;
  14.         case 1:
  15.             artyom.say("Good afternoon, how are you?");
  16.         break;            
  17.     }
  18. });

  19. // Smart command (Short code artisan way), set the second parameter of .on to true
  20. artyom.on(['Repeat after me *'] , true).then((i,wildcard) => {
  21.     artyom.say("You've said : " + wildcard);
  22. });

  23. // or add some commandsDemostrations in the normal way
  24. artyom.addCommands([
  25.     {
  26.         indexes: ['Hello','Hi','is someone there'],
  27.         action: (i) => {
  28.             artyom.say("Hello, it's me");
  29.         }
  30.     },
  31.     {
  32.         indexes: ['Repeat after me *'],
  33.         smart:true,
  34.         action: (i,wildcard) => {
  35.             artyom.say("You've said : "+ wildcard);
  36.         }
  37.     },
  38.     // The smart commands support regular expressions
  39.     {
  40.         indexes: [/Good Morning/i],
  41.         smart:true,
  42.         action: (i,wildcard) => {
  43.             artyom.say("You've said : "+ wildcard);
  44.         }
  45.     },
  46.     {
  47.         indexes: ['shut down yourself'],
  48.         action: (i,wildcard) => {
  49.             artyom.fatality().then(() => {
  50.                 console.log("Artyom succesfully stopped");
  51.             });
  52.         }
  53.     },
  54. ]);

  55. // Start the commands !
  56. artyom.initialize({
  57.     lang: "en-GB", // GreatBritain english
  58.     continuous: true, // Listen forever
  59.     soundex: true,// Use the soundex algorithm to increase accuracy
  60.     debug: true, // Show messages in the console
  61.     executionKeyword: "and do it now",
  62.     listen: true, // Start to listen commands !

  63.     // If providen, you can only trigger a command if you say its name
  64.     // e.g to trigger Good Morning, you need to say "Jarvis Good Morning"
  65.     name: "Jarvis"
  66. }).then(() => {
  67.     console.log("Artyom has been succesfully initialized");
  68. }).catch((err) => {
  69.     console.error("Artyom couldn't be initialized: ", err);
  70. });

  71. /**
  72. * To speech text
  73. */
  74. artyom.say("Hello, this is a demo text. The next text will be spoken in Spanish",{
  75.     onStart: () => {
  76.         console.log("Reading ...");
  77.     },
  78.     onEnd: () => {
  79.         console.log("No more text to talk");

  80.         // Force the language of a single speechSynthesis
  81.         artyom.say("Hola, esto está en Español", {
  82.             lang:"es-ES"
  83.         });
  84.     }
  85. });
  86. ```

All you need to know about Artyom


Documentation and FAQ

Do not hesitate to create a ticket on the issues area of the Github repository for any question, problem or inconvenient that you may have about artyom.

Development


Building Artyom from source


On every update, we build the latest version that can be retrieved from /build (for the browser and module). However, if you are willing to create your own version of Artyom, you would just need to modify the source file /source/artyom.ts and generate the build files using the following commands.

If you want to create the Browser version, you will need as first remove the export default keywords at the beginning of the class and run then the following command:

  1. ``` shell
  2. npm run build-artyom-window
  3. ```

If you want to create the Module version with CommonJS (for webpack, browserify etc) just run:

  1. ``` shell
  2. npm run build-artyom-module
  3. ```

Testing


If you're interested in modifying or working with Artyom, or you just simply want to test it quickly in your environment, we recommend you to use the little Sandbox utility of Artyom. Using Webpack, the Artyom Sandbox creates an HTTPS server accessible at https://localhost:3000, here Artyom will be accesible in Continuous mode too.

Start by cloning the repository of artyom:

  1. ``` shell
  2. git clone https://github.com/sdkcarlos/artyom.js/
  3. cd artyom.js
  4. ```

Switch to the sandbox directory:

  1. ``` shell
  2. cd sandbox
  3. ```

Then install the dependencies:

  1. ``` shell
  2. npm install
  3. ```

And start the Webpack dev server using:

  1. ``` shell
  2. npm start
  3. ```

and finally access to the https://localhost:3000 address from your browser and you will see a little UI interface to interact with Artyom. This is only meant to work on Artyom, so it still in development.

Languages


Artyom provides completesupport for the following languages. Every language needs an initialization code that needs to be provided in the lang property at the initialization.

Description Code for initialization
:--- :---
English (USA)English (Great Britain) Great Britain
Español
Deutsch (German)
Italiano
Français
Japanese 日本人
Russian
Brazil
Dutch (netherlands)
Polski (polonia)
Indonesian (Indonesia)
Chinese (Cantonese[ 粤語(香港)] Mandarin[普通话(中国大陆)])
Hindi (India)

Demonstrations


Homepage
Continuous mode J.A.R.V.I.S
Sticky Notes

Thanks


Working with artyom is cool and easy, read the documentation to discover more awesome features.

Thanks for visiting the repository !
Last Updated: 2023-05-15 10:22:02