├── .gitignore
├── README.md
├── package-lock.json
├── package.json
├── public
├── favicon.ico
├── index.html
├── logo192.png
├── logo512.png
├── manifest.json
└── robots.txt
├── server
├── .env.sample
└── server.js
└── src
├── App.css
├── App.js
├── App.test.js
├── index.css
├── index.js
├── logo.svg
├── reportWebVitals.js
└── setupTests.js
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
25 | .env
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # AssemblyAI Real-Time Microphone Transcription-React Example
2 |
3 | This open-source repo provided by AssemblyAI displays how to use our Real-time API with the React framework.
4 |
5 | In this app, we grab an audio stream from the user's computer and then send that over a WebSocket to AssemblyAI for Real-time transcription. Once AssemblyAI begins transcribing, the app displays the text in the browser. This is accomplished using Express for our backend and React for our frontend.
6 |
7 | ## How To Install and Run the Project
8 |
9 | ##### ❗Important❗
10 |
11 | - Before running this app, you need to upgrade your AssemblyAI account. The real-time API is only available to upgraded accounts at this time.
12 | - Running the app before upgrading will cause an **error with a 402 status code.** ⚠️
13 | - To upgrade your account you need to add a card. You can do that in your dashboard [here](https://www.assemblyai.com/app/)!
14 |
15 | ##### Instructions
16 |
17 | 1. Clone the repo to your local machine.
18 | 2. Open a terminal in the main directory housing the project. In this case `real-time-react`.
19 | 3. Run `npm install` to ensure all dependencies are installed.
20 | 4. Add a `.env` file to the `server` folder. Add your AssemblyAI key to the `.env` file. You can find your API key on the "Account" page in your dashboard [here](https://www.assemblyai.com/app/account). Copy and paste it into the `.env` file replacing "YOUR-PERSONAL-API-KEY" with your own key:
21 |
22 | ```
23 | ASSEMBLYAI_API_KEY="YOUR-PERSONAL-API-KEY"
24 | ```
25 |
26 | 5. Start the app with the command `npm start`. The app will run on port 3000. Open `http://localhost:3000/` in your browser and click "Record" to receive live transcription.
27 |
28 | ## Further Documentation
29 |
30 | - [AssemblyAI Real-Time Documentation](https://www.assemblyai.com/docs/speech-to-text/streaming)
31 | - [recordrtc](https://www.npmjs.com/package/recordrtc)
32 | - [Express](https://expressjs.com/)
33 |
34 | ## Contact Us
35 |
36 | If you have any questions, please feel free to reach out to our Support team - support@assemblyai.com!
37 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "real-time-react",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "@testing-library/jest-dom": "^5.17.0",
7 | "@testing-library/react": "^13.4.0",
8 | "@testing-library/user-event": "^13.5.0",
9 | "assemblyai": "^4.4.5",
10 | "concurrently": "^8.2.1",
11 | "cors": "^2.8.5",
12 | "dotenv": "^16.3.1",
13 | "express": "^4.18.2",
14 | "react": "^18.2.0",
15 | "react-dom": "^18.2.0",
16 | "react-scripts": "5.0.1",
17 | "recordrtc": "^5.6.2",
18 | "web-vitals": "^2.1.4"
19 | },
20 | "scripts": {
21 | "start": "concurrently \"react-scripts start\" \"cd server && node server.js\"",
22 | "build": "react-scripts build",
23 | "test": "react-scripts test",
24 | "eject": "react-scripts eject"
25 | },
26 | "eslintConfig": {
27 | "extends": [
28 | "react-app",
29 | "react-app/jest"
30 | ]
31 | },
32 | "browserslist": {
33 | "production": [
34 | ">0.2%",
35 | "not dead",
36 | "not op_mini all"
37 | ],
38 | "development": [
39 | "last 1 chrome version",
40 | "last 1 firefox version",
41 | "last 1 safari version"
42 | ]
43 | },
44 | "devDependencies": {
45 | "@babel/plugin-proposal-private-property-in-object": "^7.21.11"
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AssemblyAI-Community/realtime-react-example/6d91d806d4bfc3e7a5bd7681d77e7aea2ad3a139/public/favicon.ico
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |