whispermix 1.0.6 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/demo/groq.js +2 -2
- package/index.js +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ const whisperGroq = new WhisperMix({ model: 'whisper-large-v3' }); // For Groq's
|
|
|
37
37
|
|
|
38
38
|
```javascript
|
|
39
39
|
const filePath = 'path/to/your/audio/file.mp3';
|
|
40
|
-
whisperGroq.
|
|
40
|
+
whisperGroq.fromFile(filePath)
|
|
41
41
|
.then(transcription => console.log(transcription))
|
|
42
42
|
.catch(error => console.error(error));
|
|
43
43
|
```
|
|
@@ -48,7 +48,7 @@ whisperGroq.fromVoiceFile(filePath)
|
|
|
48
48
|
const fs = require('fs');
|
|
49
49
|
const audioStream = fs.createReadStream('path/to/your/audio/file.mp3');
|
|
50
50
|
|
|
51
|
-
whisperGroq.
|
|
51
|
+
whisperGroq.fromStream(audioStream)
|
|
52
52
|
.then(transcription => console.log(transcription))
|
|
53
53
|
.catch(error => console.error(error));
|
|
54
54
|
```
|
|
@@ -61,7 +61,7 @@ Creates a new WhisperMix instance.
|
|
|
61
61
|
|
|
62
62
|
- `options.model`: The model to use for transcription. Can be 'whisper-1' (OpenAI) or 'whisper-large-v3' (Groq).
|
|
63
63
|
|
|
64
|
-
### `whisper.
|
|
64
|
+
### `whisper.fromFile(filePath)`
|
|
65
65
|
|
|
66
66
|
Transcribes audio from a file.
|
|
67
67
|
|
|
@@ -69,7 +69,7 @@ Transcribes audio from a file.
|
|
|
69
69
|
|
|
70
70
|
Returns a Promise that resolves with the transcription text.
|
|
71
71
|
|
|
72
|
-
### `whisper.
|
|
72
|
+
### `whisper.fromStream(audioStream)`
|
|
73
73
|
|
|
74
74
|
Transcribes audio from a stream.
|
|
75
75
|
|
package/demo/groq.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
require('dotenv').config();
|
|
2
|
-
const fs = require('fs')
|
|
3
2
|
const WhisperMix = require('../index.js')
|
|
4
3
|
|
|
4
|
+
|
|
5
5
|
const transcribe = new WhisperMix({ model: 'whisper-large-v3' });
|
|
6
6
|
|
|
7
7
|
main(); async function main() {
|
|
8
|
-
const r = await transcribe.
|
|
8
|
+
const r = await transcribe.fromFile('./example.mp3');
|
|
9
9
|
console.log(r)
|
|
10
10
|
}
|
package/index.js
CHANGED
|
@@ -3,25 +3,25 @@ const FormData = require('form-data');
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
|
|
5
5
|
class WhisperMix {
|
|
6
|
+
|
|
6
7
|
constructor(setup = { model: 'whisper-1' }) {
|
|
7
8
|
const config = {
|
|
8
9
|
'whisper-1': {
|
|
9
10
|
url: 'https://api.openai.com/v1/audio/transcriptions',
|
|
10
|
-
|
|
11
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
11
12
|
},
|
|
12
13
|
'whisper-large-v3': {
|
|
13
14
|
url: 'https://api.groq.com/openai/v1/audio/transcriptions',
|
|
14
|
-
|
|
15
|
+
apiKey: process.env.GROQ_API_KEY,
|
|
15
16
|
},
|
|
16
17
|
};
|
|
17
18
|
|
|
18
19
|
this.model = setup.model;
|
|
19
|
-
this.apiKey =
|
|
20
|
+
this.apiKey = config[this.model].apiKey;
|
|
20
21
|
|
|
21
22
|
Object.assign(this, setup)
|
|
22
23
|
|
|
23
24
|
this.apiUrl = config[this.model].url;
|
|
24
|
-
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
async fromVoiceFile(filePath) {
|