unspeech 0.1.5 → 0.1.7
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/dist/index.d.ts +6 -6
- package/dist/index.js +106 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -209,7 +209,7 @@ interface UnElevenLabsOptions {
|
|
|
209
209
|
*/
|
|
210
210
|
declare const createUnElevenLabs: (apiKey: string, baseURL?: string) => SpeechProviderWithExtraOptions<"eleven_english_sts_v2" | "eleven_flash_v2" | "eleven_flash_v2_5" | "eleven_multilingual_sts_v2" | "eleven_multilingual_v2", UnElevenLabsOptions> & VoiceProviderWithExtraOptions<UnElevenLabsOptions>;
|
|
211
211
|
|
|
212
|
-
|
|
212
|
+
interface UnVolcengineOptions {
|
|
213
213
|
app?: {
|
|
214
214
|
appId?: string;
|
|
215
215
|
cluster?: string | 'volcano_tts';
|
|
@@ -294,7 +294,7 @@ type UnVolcanoEngineOptions = {
|
|
|
294
294
|
cacheConfig?: Record<string, unknown>;
|
|
295
295
|
useCache?: boolean;
|
|
296
296
|
};
|
|
297
|
-
}
|
|
297
|
+
}
|
|
298
298
|
/**
|
|
299
299
|
* [Volcengine / 火山引擎](https://www.volcengine.com/docs/6561/162929) provider for [UnSpeech](https://github.com/moeru-ai/unspeech)
|
|
300
300
|
* only.
|
|
@@ -308,9 +308,9 @@ type UnVolcanoEngineOptions = {
|
|
|
308
308
|
* @param baseURL - UnSpeech Instance URL
|
|
309
309
|
* @returns SpeechProviderWithExtraOptions
|
|
310
310
|
*/
|
|
311
|
-
declare const
|
|
311
|
+
declare const createUnVolcengine: (apiKey: string, baseURL?: string) => SpeechProviderWithExtraOptions<"volcengine/v1", UnVolcengineOptions> & VoiceProviderWithExtraOptions<UnVolcengineOptions>;
|
|
312
312
|
|
|
313
|
-
interface
|
|
313
|
+
interface UnAlibabaCloudOptions {
|
|
314
314
|
/**
|
|
315
315
|
* Sampling rate of the synthesized audio.
|
|
316
316
|
* @default 22050
|
|
@@ -344,7 +344,7 @@ interface UnAlibabaOptions {
|
|
|
344
344
|
* @param baseURL - UnSpeech Instance URL
|
|
345
345
|
* @returns SpeechProviderWithExtraOptions & VoiceProviderWithExtraOptions
|
|
346
346
|
*/
|
|
347
|
-
declare const
|
|
347
|
+
declare const createUnAlibabaCloud: (apiKey: string, baseURL?: string) => SpeechProviderWithExtraOptions<"alibaba/v1", UnAlibabaCloudOptions> & VoiceProviderWithExtraOptions<UnAlibabaCloudOptions>;
|
|
348
348
|
|
|
349
349
|
/** @see {@link https://github.com/moeru-ai/unspeech} */
|
|
350
350
|
declare const createUnSpeech: (apiKey: string, baseURL?: string) => _xsai_ext_shared_providers.SpeechProviderWithExtraOptions<`elevenlabs/${string}` | `koemotion/${string}` | `openai/${string}` | `volcengine/${string}` | `volcano/${string}` | `aliyun/${string}` | `alibaba/${string}`, UnSpeechOptions> & VoiceProviderWithExtraOptions<{
|
|
@@ -368,4 +368,4 @@ interface ListVoicesResponse {
|
|
|
368
368
|
}
|
|
369
369
|
declare const listVoices: (options: ListVoicesOptions) => Promise<Voice[]>;
|
|
370
370
|
|
|
371
|
-
export { type ListVoicesOptions, type ListVoicesResponse, type MicrosoftRegions, type
|
|
371
|
+
export { type ListVoicesOptions, type ListVoicesResponse, type MicrosoftRegions, type UnAlibabaCloudOptions, type UnElevenLabsOptions, type UnMicrosoftOptionAutoSSML, type UnMicrosoftOptionCommon, type UnMicrosoftOptionCustomSSML, type UnMicrosoftOptions, type UnSpeechOptions, type UnVolcengineOptions, type Voice, type VoiceFormat, type VoiceLanguage, type VoiceProvider, type VoiceProviderWithExtraOptions, createUnAlibabaCloud, createUnElevenLabs, createUnMicrosoft, createUnSpeech, createUnVolcengine, listVoices };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/backend/index.ts
|
|
2
|
-
import { createSpeechProviderWithExtraOptions, merge as
|
|
2
|
+
import { createSpeechProviderWithExtraOptions, merge as merge5 } from "@xsai-ext/shared-providers";
|
|
3
3
|
|
|
4
4
|
// src/backend/elevenlabs.ts
|
|
5
5
|
import { merge } from "@xsai-ext/shared-providers";
|
|
@@ -109,6 +109,108 @@ var createUnMicrosoft = (apiKey, baseURL = "http://localhost:5933/v1/") => {
|
|
|
109
109
|
);
|
|
110
110
|
};
|
|
111
111
|
|
|
112
|
+
// src/backend/volcengine.ts
|
|
113
|
+
import { merge as merge3 } from "@xsai-ext/shared-providers";
|
|
114
|
+
import { objCamelToSnake as objCamelToSnake3 } from "@xsai/shared";
|
|
115
|
+
var createUnVolcengine = (apiKey, baseURL = "http://localhost:5933/v1/") => {
|
|
116
|
+
const toUnSpeechOptions = (options) => {
|
|
117
|
+
const extraBody = {
|
|
118
|
+
app: {
|
|
119
|
+
appid: options.app?.appId,
|
|
120
|
+
token: apiKey
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
if (typeof options.app !== "undefined") {
|
|
124
|
+
extraBody.app = {
|
|
125
|
+
...options.app,
|
|
126
|
+
appid: options.app?.appId,
|
|
127
|
+
token: apiKey
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
if (typeof options.user !== "undefined") {
|
|
131
|
+
extraBody.user = options.user;
|
|
132
|
+
}
|
|
133
|
+
if (typeof options.audio !== "undefined") {
|
|
134
|
+
extraBody.audio = options.audio;
|
|
135
|
+
}
|
|
136
|
+
return { extraBody: objCamelToSnake3(extraBody) };
|
|
137
|
+
};
|
|
138
|
+
const speechProvider = {
|
|
139
|
+
speech: (model, options) => ({
|
|
140
|
+
...options ? toUnSpeechOptions(options) : {},
|
|
141
|
+
apiKey,
|
|
142
|
+
baseURL,
|
|
143
|
+
model: `volcengine/${model}`
|
|
144
|
+
})
|
|
145
|
+
};
|
|
146
|
+
const voiceProvider = {
|
|
147
|
+
voice: (options) => {
|
|
148
|
+
if (baseURL.endsWith("v1/")) {
|
|
149
|
+
baseURL = baseURL.slice(0, -3);
|
|
150
|
+
} else if (baseURL.endsWith("v1")) {
|
|
151
|
+
baseURL = baseURL.slice(0, -2);
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
query: `provider=volcengine`,
|
|
155
|
+
...options ? toUnSpeechOptions(options) : {},
|
|
156
|
+
apiKey,
|
|
157
|
+
baseURL
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
return merge3(
|
|
162
|
+
speechProvider,
|
|
163
|
+
voiceProvider
|
|
164
|
+
);
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
// src/backend/alibabacloud.ts
|
|
168
|
+
import { merge as merge4 } from "@xsai-ext/shared-providers";
|
|
169
|
+
import { objCamelToSnake as objCamelToSnake4 } from "@xsai/shared";
|
|
170
|
+
var createUnAlibabaCloud = (apiKey, baseURL = "http://localhost:5933/v1/") => {
|
|
171
|
+
const toUnSpeechOptions = (options) => {
|
|
172
|
+
const { sampleRate, volume, rate, pitch } = options;
|
|
173
|
+
const extraBody = {
|
|
174
|
+
sampleRate,
|
|
175
|
+
volume,
|
|
176
|
+
rate,
|
|
177
|
+
pitch
|
|
178
|
+
};
|
|
179
|
+
Object.keys(extraBody).forEach((key) => extraBody[key] === void 0 && delete extraBody[key]);
|
|
180
|
+
return { extraBody: objCamelToSnake4(extraBody) };
|
|
181
|
+
};
|
|
182
|
+
const speechProvider = {
|
|
183
|
+
speech: (model, options) => ({
|
|
184
|
+
...options ? toUnSpeechOptions(options) : {},
|
|
185
|
+
apiKey,
|
|
186
|
+
baseURL,
|
|
187
|
+
// Model is used directly, e.g., "sifeng"
|
|
188
|
+
// The backend prepends the necessary task group/task/function info
|
|
189
|
+
model: `alibaba/${model}`
|
|
190
|
+
})
|
|
191
|
+
};
|
|
192
|
+
const voiceProvider = {
|
|
193
|
+
voice: (options) => {
|
|
194
|
+
let adjustedBaseURL = baseURL;
|
|
195
|
+
if (adjustedBaseURL.endsWith("v1/")) {
|
|
196
|
+
adjustedBaseURL = adjustedBaseURL.slice(0, -3);
|
|
197
|
+
} else if (adjustedBaseURL.endsWith("v1")) {
|
|
198
|
+
adjustedBaseURL = adjustedBaseURL.slice(0, -2);
|
|
199
|
+
}
|
|
200
|
+
return {
|
|
201
|
+
query: "provider=alibaba",
|
|
202
|
+
...options ? toUnSpeechOptions(options) : {},
|
|
203
|
+
apiKey,
|
|
204
|
+
baseURL: adjustedBaseURL
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
return merge4(
|
|
209
|
+
speechProvider,
|
|
210
|
+
voiceProvider
|
|
211
|
+
);
|
|
212
|
+
};
|
|
213
|
+
|
|
112
214
|
// src/backend/index.ts
|
|
113
215
|
var createUnSpeech = (apiKey, baseURL = "http://localhost:5933/v1/") => {
|
|
114
216
|
const voiceProvider = {
|
|
@@ -132,7 +234,7 @@ var createUnSpeech = (apiKey, baseURL = "http://localhost:5933/v1/") => {
|
|
|
132
234
|
};
|
|
133
235
|
}
|
|
134
236
|
};
|
|
135
|
-
return
|
|
237
|
+
return merge5(
|
|
136
238
|
createSpeechProviderWithExtraOptions({ apiKey, baseURL }),
|
|
137
239
|
voiceProvider
|
|
138
240
|
);
|
|
@@ -146,8 +248,10 @@ var listVoices = async (options) => (options.fetch ?? globalThis.fetch)(requestU
|
|
|
146
248
|
signal: options.abortSignal
|
|
147
249
|
}).then(responseJSON).then(({ voices }) => voices);
|
|
148
250
|
export {
|
|
251
|
+
createUnAlibabaCloud,
|
|
149
252
|
createUnElevenLabs,
|
|
150
253
|
createUnMicrosoft,
|
|
151
254
|
createUnSpeech,
|
|
255
|
+
createUnVolcengine,
|
|
152
256
|
listVoices
|
|
153
257
|
};
|