├── .babelrc ├── .circleci └── config.yml ├── .eslintrc ├── .gitignore ├── .npmignore ├── .prettierrc ├── README.md ├── examples └── src │ ├── images │ ├── favicon.ico │ └── github.png │ ├── index.html │ ├── index.jsx │ ├── shared.js │ ├── useSpeechRecognition.jsx │ └── useSpeechSynthesis.jsx ├── jest.setup.js ├── package.json ├── src ├── index.js ├── useSpeechRecognition.js └── useSpeechSynthesis.jsx ├── test ├── mocks │ ├── MockRecognition.jsx │ ├── MockSynthesis.js │ └── MockUtterance.js ├── shared │ └── speechSynthesisTests.jsx ├── useSpeechRecognition.spec.jsx └── useSpeechSynthesis.spec.jsx ├── webpack.config.js └── yarn.lock /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["env", "react"] 3 | } 4 | -------------------------------------------------------------------------------- /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | # Javascript Node CircleCI 2.0 configuration file 2 | # 3 | # Check https://circleci.com/docs/2.0/language-javascript/ for more details 4 | # 5 | version: 2.1 6 | jobs: 7 | build: 8 | docker: 9 | # specify the version you desire here 10 | - image: circleci/node:10.15 11 | 12 | # Specify service dependencies here if necessary 13 | # CircleCI maintains a library of pre-built images 14 | # documented at https://circleci.com/docs/2.0/circleci-images/ 15 | # - image: circleci/mongo:3.4.4 16 | 17 | working_directory: ~/repo 18 | 19 | steps: 20 | - checkout 21 | 22 | # Download and cache dependencies 23 | - restore_cache: 24 | keys: 25 | - v1-dependencies-{{ checksum "package.json" }} 26 | # fallback to using the latest cache if no exact match is found 27 | - v1-dependencies- 28 | 29 | - run: yarn install 30 | 31 | - save_cache: 32 | paths: 33 | - node_modules 34 | key: v1-dependencies-{{ checksum "package.json" }} 35 | 36 | # run tests! 37 | - run: yarn test 38 | - run: 39 | name: Generate code coverage 40 | command: './node_modules/.bin/codecov' 41 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "globals": { 3 | "document": true, 4 | "window": true 5 | }, 6 | "env": { 7 | "jest/globals": true 8 | }, 9 | "extends": ["airbnb", "plugin:prettier/recommended"], 10 | "parser": "babel-eslint", 11 | "parserOptions": { 12 | "ecmaFeatures": { 13 | "experimentalObjectRestSpread": true, 14 | "jsx": true, 15 | "es6": true 16 | }, 17 | "sourceType": "module" 18 | }, 19 | "plugins": ["babel", "jest", "react", "prettier"], 20 | "rules": { 21 | "prettier/prettier": "error", 22 | "object-curly-newline": "off", 23 | "jsx-a11y/label-has-associated-control": [ 24 | "error", 25 | { 26 | "labelComponents": [], 27 | "labelAttributes": [], 28 | "controlComponents": [], 29 | "assert": "either", 30 | "depth": 25 31 | } 32 | ], 33 | "jsx-a11y/label-has-for": [ 34 | 2, 35 | { 36 | "required": { 37 | "some": ["nesting", "id"] 38 | } 39 | } 40 | ], 41 | "import/no-extraneous-dependencies": [ 42 | "error", 43 | { "devDependencies": ["examples/src/*", "**/*.spec.js", "**/*.spec.jsx"] } 44 | ], 45 | "import/no-unresolved": ["error", { "ignore": ["^react$"] }] 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | coverage 3 | .DS_Store 4 | /node_modules 5 | yarn-error.log 6 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | *.log 3 | 4 | # Development files 5 | src 6 | examples 7 | 8 | # Test 9 | coverage 10 | test 11 | 12 | # Config 13 | .gitignore 14 | .babelrc 15 | webpack.config.js 16 | .circleci 17 | jest.setup.js 18 | .eslintrc 19 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "useTabs": false, 3 | "singleQuote": true 4 | } 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # react-speech-kit 🎤    [![CircleCI](https://circleci.com/gh/MikeyParton/react-speech-kit/tree/master.svg?style=shield)](https://circleci.com/gh/MikeyParton/react-speech-kit/tree/master) [![codecov](https://codecov.io/gh/MikeyParton/react-speech-kit/branch/master/graph/badge.svg)](https://codecov.io/gh/MikeyParton/react-speech-kit) 2 | 3 | React hooks for in-browser Speech Recognition and Speech Synthesis. 4 | [Demo here](https://mikeyparton.github.io/react-speech-kit/) 5 | 6 | ## Table of Contents 7 | 8 | - [Install](#install) 9 | - [Examples and Demo](#examples-and-demo) 10 | - [useSpeechSynthesis](#usespeechsynthesis) 11 | - [Usage](#usage) 12 | - [Args](#args) 13 | - [Returns](#returns) 14 | - [useSpeechRecognition](#usespeechrecognition) 15 | - [Usage](#usage-1) 16 | - [Args](#args-1) 17 | - [Returns](#returns-1) 18 | 19 | ## Install 20 | 21 | ```bash 22 | yarn add react-speech-kit 23 | ``` 24 | 25 | ## Examples and Demo 26 | 27 | A full example can be found [here](https://mikeyparton.github.io/react-speech-kit/). The source code is in the [examples directory](https://github.com/MikeyParton/react-speech-kit/tree/master/examples/src). 28 | 29 | ## useSpeechSynthesis 30 | 31 | A react hook for the browser's [SpeechSynthesis API](https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesis). It exposes the options and controls to the underlying SpeechSynthesis in the browser. 32 | 33 | ### Usage 34 | 35 | ```jsx 36 | import React, { useState } from 'react'; 37 | import { useSpeechSynthesis } from 'react-speech-kit'; 38 | 39 | function Example() { 40 | const [value, setValue] = useState(''); 41 | const { speak } = useSpeechSynthesis(); 42 | 43 | return ( 44 |
45 |