voicemix 1.2.4 → 1.2.8

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "voicemix",
3
3
  "type": "module",
4
- "version": "1.2.4",
4
+ "version": "1.2.8",
5
5
  "description": "🗣️ VoiceMix - A simple text-to-speech tool using ElevenLabs, Cartesia and Resemble AI APIs.",
6
6
  "main": "index.js",
7
7
  "repository": {
@@ -14,7 +14,7 @@
14
14
  "author": "Martin Clasen",
15
15
  "license": "MIT",
16
16
  "dependencies": {
17
- "axios": "^1.9.0",
17
+ "axios": "^1.13.4",
18
18
  "hash-factory": "^1.1.2"
19
19
  },
20
20
  "keywords": [
@@ -31,4 +31,4 @@
31
31
  "cartesia",
32
32
  "clasen"
33
33
  ]
34
- }
34
+ }
@@ -1,6 +1,7 @@
1
1
  import axios from 'axios';
2
2
  import fs from 'fs';
3
3
  import path from 'path';
4
+ import { pipeline } from 'stream/promises';
4
5
  import { ProviderError } from '../errors.js';
5
6
 
6
7
  export class CartesiaProvider {
@@ -70,18 +71,21 @@ export class CartesiaProvider {
70
71
 
71
72
  const fullPath = path.join(filePath, fileName);
72
73
  const writer = fs.createWriteStream(fullPath);
73
- response.data.pipe(writer);
74
74
 
75
- return new Promise((resolve, reject) => {
76
- writer.on('finish', () => resolve(fullPath));
77
- writer.on('error', (err) => {
78
- reject(new ProviderError(
79
- 'Failed to write audio file',
80
- 'cartesia',
81
- { path: fullPath, error: err.message }
82
- ));
83
- });
84
- });
75
+ try {
76
+ await pipeline(response.data, writer);
77
+ return fullPath;
78
+ } catch (err) {
79
+ // Clean up partial file on failure
80
+ if (fs.existsSync(fullPath)) {
81
+ fs.unlinkSync(fullPath);
82
+ }
83
+ throw new ProviderError(
84
+ 'Failed to write audio file',
85
+ 'cartesia',
86
+ { path: fullPath, error: err.message }
87
+ );
88
+ }
85
89
  } catch (error) {
86
90
  if (error instanceof ProviderError) {
87
91
  throw error;
@@ -1,6 +1,7 @@
1
1
  import axios from 'axios';
2
2
  import fs from 'fs';
3
3
  import path from 'path';
4
+ import { pipeline } from 'stream/promises';
4
5
  import { ProviderError } from '../errors.js';
5
6
 
6
7
  export class ElevenLabsProvider {
@@ -36,6 +37,10 @@ export class ElevenLabsProvider {
36
37
 
37
38
  v3() {
38
39
  this.model_id = 'eleven_v3';
40
+ this.voice_settings = {
41
+ stability: this.voice_settings.stability,
42
+ };
43
+
39
44
  return this;
40
45
  }
41
46
 
@@ -80,18 +85,21 @@ export class ElevenLabsProvider {
80
85
 
81
86
  const fullPath = path.join(filePath, fileName);
82
87
  const writer = fs.createWriteStream(fullPath);
83
- response.data.pipe(writer);
84
88
 
85
- return new Promise((resolve, reject) => {
86
- writer.on('finish', () => resolve(fullPath));
87
- writer.on('error', (err) => {
88
- reject(new ProviderError(
89
- 'Failed to write audio file',
90
- 'elevenlabs',
91
- { path: fullPath, error: err.message }
92
- ));
93
- });
94
- });
89
+ try {
90
+ await pipeline(response.data, writer);
91
+ return fullPath;
92
+ } catch (err) {
93
+ // Clean up partial file on failure
94
+ if (fs.existsSync(fullPath)) {
95
+ fs.unlinkSync(fullPath);
96
+ }
97
+ throw new ProviderError(
98
+ 'Failed to write audio file',
99
+ 'elevenlabs',
100
+ { path: fullPath, error: err.message }
101
+ );
102
+ }
95
103
  } catch (error) {
96
104
  if (error instanceof ProviderError) {
97
105
  throw error;