├── .eslintignore
├── .eslintrc
├── .github
└── workflows
│ └── publish.yml
├── .gitignore
├── .prettierrc.json
├── LICENSE
├── README.md
├── jestconfig.json
├── package-lock.json
├── package.json
├── src
├── __tests__
│ └── index.test.ts
├── assets
│ └── logo.png
├── hooks
│ ├── index.ts
│ ├── useTextToVoice.ts
│ └── useVoiceToText.ts
└── index.ts
└── tsconfig.json
/.eslintignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dist
--------------------------------------------------------------------------------
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "root": true,
3 | "extends": [
4 | "prettier",
5 | "plugin:prettier/recommended",
6 | "eslint:recommended",
7 | "plugin:react/recommended",
8 | "plugin:@typescript-eslint/eslint-recommended",
9 | "plugin:@typescript-eslint/recommended"
10 | ],
11 | "parser": "@typescript-eslint/parser",
12 | "plugins": ["prettier", "@typescript-eslint", "react", "react-hooks"],
13 | "rules": {
14 | "react-hooks/rules-of-hooks": "error",
15 | "react-hooks/exhaustive-deps": "warn",
16 | "@typescript-eslint/no-non-null-assertion": "off",
17 | "@typescript-eslint/ban-ts-comment": "off",
18 | "@typescript-eslint/no-explicit-any": "off"
19 | },
20 | "settings": {
21 | "react": {
22 | "version": "detect"
23 | }
24 | },
25 | "env": {
26 | "browser": true,
27 | "node": true
28 | },
29 | "globals": {
30 | "JSX": true
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/.github/workflows/publish.yml:
--------------------------------------------------------------------------------
1 | # This is a name of the workflow
2 | name: build
3 | # Controls when the workflow will run
4 | on:
5 | # Triggers the workflow on published releases
6 | release:
7 | types: [published]
8 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel
9 | jobs:
10 | # This workflow contains a single job called "build"
11 | build:
12 | # The type of runner that the job will run on
13 | runs-on: ubuntu-latest
14 | # Steps represent a sequence of tasks that will be executed as part of the job
15 | steps:
16 |
17 | - name: Checkout
18 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
19 | uses: actions/checkout@v3
20 |
21 | - name: Setup Node
22 | # Setup node environment
23 | uses: actions/setup-node@v3
24 | with:
25 | # Node version. Run "node -v" to check the latest version
26 | node-version: 21.x
27 | registry-url: https://registry.npmjs.org/
28 |
29 | - name: Install dependencies
30 | run: yarn && yarn install
31 |
32 | - name: Build
33 | run: yarn build
34 |
35 | - name: Publish
36 | run: yarn publish
37 |
38 | env:
39 | # We need this to our NPM account
40 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dist
3 | yarn-error.log
--------------------------------------------------------------------------------
/.prettierrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "bracketSpacing": true,
3 | "singleQuote": true,
4 | "trailingComma": "all",
5 | "tabWidth": 2,
6 | "semi": false,
7 | "printWidth": 120,
8 | "jsxSingleQuote": true,
9 | "endOfLine": "auto"
10 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Amin Partovi
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 | # Overview
4 | React SpeakUp is a powerful React package designed to streamline voice interaction within your web applications. Leveraging the Web Speech API, it empowers developers to effortlessly integrate speech recognition and synthesis functionalities into React.js and Next.js projects.
5 |
6 | ### Key Features:
7 |
8 | #### 1. **Voice to Text Conversion:**
9 |
10 | - Effortlessly convert spoken words into text with our intuitive `useVoiceToText` hook.
11 | - Speak with your native language and receive exact results.
12 |
13 | #### 2. **Text to Voice Synthesis:**
14 |
15 | - Transform text content into spoken words using the versatile `useTextToVoice` hook.
16 | - Fine-tune voice characteristics such as pitch, rate, and volume for a personalized experience.
17 |
18 | #### 3. **TypeScript Integration:**
19 | - Seamless integration with TypeScript ensures a robust development experience.
20 |
21 | #### 4. **Easy Integration:**
22 | - Compatible with up to date versions of React.js and Next.js.
23 |
24 | #### 5. **Styling Freedom:**
25 |
26 | - Unrestricted styling possibilities and no limitations on customization.
27 |
28 |
29 | # Getting Started
30 | Install via your favorite package manager
31 |
32 | ### Installation
33 |
34 | npm install react-speakup
35 | or
36 |
37 | yarn add react-speakup
38 |
39 |
40 | ### Usage
41 | Convert voice to text with `useVoiceToText`
42 |
43 | ```jsx
44 | import React from "react";
45 | import { useVoiceToText } from "react-speakup";
46 |
47 | const VoiceToTextComponent = () => {
48 | const { startListening, stopListening, transcript, reset } = useVoiceToText();
49 |
50 | return (
51 |
52 |
53 |
54 |
55 | {transcript}
56 |
57 | );
58 | };
59 |
60 | export default VoiceToTextComponent;
61 | ```
62 | `useVoiceToText` can take these options
63 | | Properties | Description | Default Value |
64 | |----------|----------|----------|
65 | | lang | the language you are speaking, e.g. "en-US" or "fa-IR" | "en-US" |
66 | | continuous | if its true, it'll stop listening manually, otherwise it stop listening anytime the speech will finished | true |
67 |
68 |
69 |
70 | Convert text to voice with `useTextToVoice`
71 | ```jsx
72 | import React from "react";
73 | import { useTextToVoice } from "react-speakup";
74 |
75 | const TextToVoiceComponent = () => {
76 | const { speak, pause, resume, ref, setVoice, voices } = useTextToVoice();
77 |
78 | return (
79 |
80 |
81 |
82 |
83 |
92 |
93 |
It's not important which HTML tag your text is within.