1
- # useWhisper
1
+ # useWhisper()
2
2
3
3
React Hook for OpenAI Whisper API with speech recorder and silence removal built-in
4
4
5
5
---
6
6
7
- _ Try OpenAI API price calculator, token counter, and dataset manager (preview)_
7
+ _ Try OpenAI API price calculator, token counter, and dataset manager (preview)_
8
8
[ https://openai-price-calculator.web.app ] ( https://openai-price-calculator.web.app )
9
9
10
10
- ### Install
@@ -24,8 +24,8 @@ const App = () => {
24
24
const {
25
25
recording ,
26
26
speaking ,
27
+ transcribing ,
27
28
transcript ,
28
- transcripting ,
29
29
pauseRecording ,
30
30
startRecording ,
31
31
stopRecording ,
@@ -37,7 +37,7 @@ const App = () => {
37
37
< div>
38
38
< p> Recording: {recording}< / p>
39
39
< p> Speaking: {speaking}< / p>
40
- < p> Transcripting : {transcripting }< / p>
40
+ < p> Transcribing : {transcribing }< / p>
41
41
< p> Transcribed Text : {transcript .text }< / p>
42
42
< button onClick= {() => startRecording ()}> Start< / button>
43
43
< button onClick= {() => pauseRecording ()}> Pause< / button>
@@ -117,7 +117,6 @@ import { useWhisper } from '@chengsokdara/use-whisper'
117
117
const App = () => {
118
118
const { transcript } = useWhisper ({
119
119
// will auto start recording speech upon component mounted
120
- //
121
120
autoStart: true ,
122
121
})
123
122
@@ -151,10 +150,13 @@ const App = () => {
151
150
152
151
- ### Dependencies
153
152
154
- - ** recordrtc:** cross-browser audio recorder
155
- - ** @ffmpeg/ffmpeg :** for remove silence feature
156
- - ** hark:** for speaking detection
157
- - ** axios:** since fetch does not work with Whisper API
153
+ most of these dependecies are lazy loaded, so it is only imported when it is needed
154
+
155
+ - ** @chengsokdara/react-hooks-async ** asynchronous react hooks
156
+ - ** recordrtc:** cross-browser audio recorder
157
+ - ** @ffmpeg/ffmpeg :** for silence removal feature
158
+ - ** hark:** for speaking detection
159
+ - ** axios:** since fetch does not work with Whisper endpoint
158
160
159
161
- ### API
160
162
@@ -171,15 +173,15 @@ const App = () => {
171
173
172
174
- ###### Return Object
173
175
174
- | Name | Type | Description |
175
- | -------------- | ----------------------------- | ----------------------------------------------------------------- |
176
- | recording | boolean | speech recording state |
177
- | speaking | boolean | detect when user is speaking |
178
- | transcript | [ ** Transcript ** ] ( #transcript ) | object return after Whisper transcription complete |
179
- | transcripting | boolean | remove silence from speech and send request to OpenAI Whisper API |
180
- | pauseRecording | Promise | pause speech recording |
181
- | startRecording | Promise | start speech recording |
182
- | stopRecording | Promise | stop speech recording |
176
+ | Name | Type | Description |
177
+ | -------------- | ----------------------------- | ------------------------------------------------------------------------- |
178
+ | recording | boolean | speech recording state |
179
+ | speaking | boolean | detect when user is speaking |
180
+ | transcribing | boolean | while removing silence from speech and send request to OpenAI Whisper API |
181
+ | transcript | [ ** Transcript ** ] ( #transcript ) | object return after Whisper transcription complete |
182
+ | pauseRecording | Promise | pause speech recording |
183
+ | startRecording | Promise | start speech recording |
184
+ | stopRecording | Promise | stop speech recording |
183
185
184
186
- ###### Transcript
185
187
@@ -188,6 +190,10 @@ const App = () => {
188
190
| blob | Blob | recorded speech in JavaScript Blob |
189
191
| text | string | transcribed text returned from Whisper API |
190
192
193
+ - ### Roadmap
194
+
195
+ - react-native support, will be export as use-whisper/native
196
+
191
197
---
192
198
193
199
** _ Contact me for web or mobile app development using React or React Native_ **
0 commit comments