unspeech 0.1.16 → 0.1.20
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 +2 -0
- package/dist/index.d.mts +163 -3
- package/dist/index.mjs +40 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -51,6 +51,7 @@ import {
|
|
|
51
51
|
createUnAlibabaCloud,
|
|
52
52
|
createUnElevenLabs,
|
|
53
53
|
createUnMicrosoft,
|
|
54
|
+
createUnMinimax,
|
|
54
55
|
createUnSpeech,
|
|
55
56
|
createUnVolcengine,
|
|
56
57
|
} from 'unspeech'
|
|
@@ -62,6 +63,7 @@ When using
|
|
|
62
63
|
- [Alibaba Cloud Model Studio / 阿里云百炼 / CosyVoice](https://www.alibabacloud.com/en/product/modelstudio)
|
|
63
64
|
- [Volcano Engine / 火山引擎语音技术](https://www.volcengine.com/product/voice-tech)
|
|
64
65
|
- [ElevenLabs](https://elevenlabs.io/docs/api-reference/text-to-speech/convert)
|
|
66
|
+
- [MiniMax](https://platform.minimaxi.com/docs/guides/speech-t2a-http)
|
|
65
67
|
|
|
66
68
|
providers, [SSML](https://learn.microsoft.com/en-us/azure/ai-services/speech-service/speech-synthesis-markup) is supported to control in fine grain level for pitch, volume, rate, etc.
|
|
67
69
|
|
package/dist/index.d.mts
CHANGED
|
@@ -353,8 +353,168 @@ interface UnElevenLabsOptions {
|
|
|
353
353
|
*/
|
|
354
354
|
declare function 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>;
|
|
355
355
|
//#endregion
|
|
356
|
+
//#region src/backend/fishaudio.d.ts
|
|
357
|
+
/** @see {@link https://docs.fish.audio/api-reference/endpoint/openapi-v1/text-to-speech} */
|
|
358
|
+
interface UnFishAudioOptions {
|
|
359
|
+
/**
|
|
360
|
+
* Text segment length used when splitting long input.
|
|
361
|
+
* Range: 100 to 300.
|
|
362
|
+
*
|
|
363
|
+
* @default 200
|
|
364
|
+
*/
|
|
365
|
+
chunkLength?: number;
|
|
366
|
+
/**
|
|
367
|
+
* Latency mode. `balanced` reduces latency at a slight cost to stability.
|
|
368
|
+
*
|
|
369
|
+
* @default 'normal'
|
|
370
|
+
*/
|
|
371
|
+
latency?: 'balanced' | 'normal';
|
|
372
|
+
/**
|
|
373
|
+
* MP3 bitrate in kbps, only used with the mp3 format.
|
|
374
|
+
*
|
|
375
|
+
* @default 128
|
|
376
|
+
*/
|
|
377
|
+
mp3Bitrate?: 64 | 128 | 192;
|
|
378
|
+
/**
|
|
379
|
+
* Normalize text (e.g. spell out numbers) for better stability.
|
|
380
|
+
*
|
|
381
|
+
* @default true
|
|
382
|
+
*/
|
|
383
|
+
normalize?: boolean;
|
|
384
|
+
/**
|
|
385
|
+
* Speech pacing controls.
|
|
386
|
+
*/
|
|
387
|
+
prosody?: {
|
|
388
|
+
/**
|
|
389
|
+
* Speed multiplier, 1.0 is normal speed.
|
|
390
|
+
*
|
|
391
|
+
* @default 1
|
|
392
|
+
*/
|
|
393
|
+
speed?: number;
|
|
394
|
+
/**
|
|
395
|
+
* Volume gain in dB, 0 is unchanged.
|
|
396
|
+
*
|
|
397
|
+
* @default 0
|
|
398
|
+
*/
|
|
399
|
+
volume?: number;
|
|
400
|
+
};
|
|
401
|
+
/**
|
|
402
|
+
* Output sample rate in Hz.
|
|
403
|
+
*/
|
|
404
|
+
sampleRate?: number;
|
|
405
|
+
/**
|
|
406
|
+
* Sampling temperature; lower is more deterministic.
|
|
407
|
+
*
|
|
408
|
+
* @default 0.7
|
|
409
|
+
*/
|
|
410
|
+
temperature?: number;
|
|
411
|
+
/**
|
|
412
|
+
* Nucleus sampling threshold.
|
|
413
|
+
*
|
|
414
|
+
* @default 0.7
|
|
415
|
+
*/
|
|
416
|
+
topP?: number;
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* [Fish Audio](https://fish.audio/) provider for
|
|
420
|
+
* [UnSpeech](https://github.com/moeru-ai/unspeech).
|
|
421
|
+
*
|
|
422
|
+
* The OpenAI `voice` parameter maps to a Fish Audio reference voice model id
|
|
423
|
+
* (the id in a fish.audio voice page URL).
|
|
424
|
+
*
|
|
425
|
+
* @param apiKey - Fish Audio API key
|
|
426
|
+
* @param baseURL - UnSpeech Instance URL
|
|
427
|
+
* @returns SpeechProviderWithExtraOptions
|
|
428
|
+
*/
|
|
429
|
+
declare function createUnFishAudio(apiKey: string, baseURL?: string): SpeechProviderWithExtraOptions<`fishaudio/${string}`, UnFishAudioOptions> & VoiceProviderWithExtraOptions<UnFishAudioOptions>;
|
|
430
|
+
//#endregion
|
|
431
|
+
//#region src/backend/minimax.d.ts
|
|
432
|
+
/**
|
|
433
|
+
* MiniMax TTS API options
|
|
434
|
+
* @see https://platform.minimaxi.com/docs/guides/speech-t2a-http
|
|
435
|
+
*/
|
|
436
|
+
interface UnMinimaxOptions {
|
|
437
|
+
/**
|
|
438
|
+
* Speech speed. Range: 0.5-2.0
|
|
439
|
+
* @default 1.0
|
|
440
|
+
*/
|
|
441
|
+
speed?: number;
|
|
442
|
+
/**
|
|
443
|
+
* Volume. Range: 0-10
|
|
444
|
+
* @default 1.0
|
|
445
|
+
*/
|
|
446
|
+
vol?: number;
|
|
447
|
+
/**
|
|
448
|
+
* Pitch adjustment. Range: -12 to 12
|
|
449
|
+
* @default 0
|
|
450
|
+
*/
|
|
451
|
+
pitch?: number;
|
|
452
|
+
/**
|
|
453
|
+
* Emotion setting
|
|
454
|
+
* @see https://platform.minimaxi.com/docs/guides/speech-t2a-http#emotion
|
|
455
|
+
* @example "happy" | "sad" | "angry" | "fearful" | "disgusted" | "surprised" | "calm" | "fluent" | "whisper"
|
|
456
|
+
*/
|
|
457
|
+
emotion?: string;
|
|
458
|
+
/**
|
|
459
|
+
* Enable streaming output
|
|
460
|
+
* @default false
|
|
461
|
+
*/
|
|
462
|
+
stream?: boolean;
|
|
463
|
+
/**
|
|
464
|
+
* Sample rate for audio output
|
|
465
|
+
* @example 8000 | 16000 | 22050 | 24000 | 32000 | 44100
|
|
466
|
+
*/
|
|
467
|
+
sampleRate?: number;
|
|
468
|
+
/**
|
|
469
|
+
* Audio bitrate
|
|
470
|
+
* @example 32000 | 64000 | 128000 | 256000
|
|
471
|
+
*/
|
|
472
|
+
bitrate?: number;
|
|
473
|
+
/**
|
|
474
|
+
* Audio format
|
|
475
|
+
* @example "mp3" | "pcm" | "flac" | "wav"
|
|
476
|
+
* @default "mp3"
|
|
477
|
+
*/
|
|
478
|
+
format?: 'mp3' | 'pcm' | 'flac' | 'wav';
|
|
479
|
+
/**
|
|
480
|
+
* Audio channel
|
|
481
|
+
* @example 1 | 2
|
|
482
|
+
* @default 1
|
|
483
|
+
*/
|
|
484
|
+
channel?: number;
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* MiniMax TTS models
|
|
488
|
+
* @see https://platform.minimaxi.com/docs/guides/speech-t2a-http#model
|
|
489
|
+
*/
|
|
490
|
+
type MinimaxModel = 'speech-2.8-hd' | 'speech-2.8-turbo' | 'speech-2.6-hd' | 'speech-2.6-turbo' | 'speech-02-hd' | 'speech-02-turbo' | 'speech-01-hd' | 'speech-01-turbo';
|
|
491
|
+
/**
|
|
492
|
+
* [MiniMax](https://platform.minimaxi.com/) provider for [UnSpeech](https://github.com/moeru-ai/unspeech)
|
|
493
|
+
*
|
|
494
|
+
* @param apiKey - MiniMax API Key
|
|
495
|
+
* @param baseURL - UnSpeech Instance URL
|
|
496
|
+
* @returns SpeechProviderWithExtraOptions & VoiceProviderWithExtraOptions
|
|
497
|
+
*/
|
|
498
|
+
declare function createUnMinimax(apiKey: string, baseURL?: string): SpeechProviderWithExtraOptions<"minimax/speech-2.8-hd" | "minimax/speech-2.8-turbo" | "minimax/speech-2.6-hd" | "minimax/speech-2.6-turbo" | "minimax/speech-02-hd" | "minimax/speech-02-turbo" | "minimax/speech-01-hd" | "minimax/speech-01-turbo", UnMinimaxOptions> & VoiceProviderWithExtraOptions<UnMinimaxOptions>;
|
|
499
|
+
//#endregion
|
|
356
500
|
//#region src/backend/stepfun.d.ts
|
|
357
501
|
interface UnStepfunOptions {
|
|
502
|
+
/**
|
|
503
|
+
* Selects a StepFun-defined API endpoint without exposing an arbitrary URL.
|
|
504
|
+
*
|
|
505
|
+
* Use `step-plan` for requests covered by a Step Plan subscription. Omit
|
|
506
|
+
* this option, or use `default`, for StepFun's default speech endpoint.
|
|
507
|
+
*
|
|
508
|
+
* @default 'default'
|
|
509
|
+
*/
|
|
510
|
+
endpointProfile?: 'default' | 'step-plan';
|
|
511
|
+
/**
|
|
512
|
+
* The language that StepFun reads the text in, for example `en` or `ja`.
|
|
513
|
+
*
|
|
514
|
+
* Without it, a short or mixed text, such as a digit next to Latin letters,
|
|
515
|
+
* can be read in the language of the voice.
|
|
516
|
+
*/
|
|
517
|
+
language?: 'zh' | 'en' | 'ja' | 'ko' | 'fr' | 'es' | string;
|
|
358
518
|
/**
|
|
359
519
|
* Audio volume. Range: 0.1 to 2.0.
|
|
360
520
|
*
|
|
@@ -500,7 +660,7 @@ declare function createUnVolcengine(apiKey: string, baseURL?: string): SpeechPro
|
|
|
500
660
|
//#endregion
|
|
501
661
|
//#region src/backend/index.d.ts
|
|
502
662
|
/** @see {@link https://github.com/moeru-ai/unspeech} */
|
|
503
|
-
declare function createUnSpeech(apiKey: string, baseURL?: string): _xsai_ext_providers_utils0.SpeechProviderWithExtraOptions<`alibaba/${string}` | `aliyun/${string}` | `deepgram/${string}` | `elevenlabs/${string}` | `koemotion/${string}` | `openai/${string}` | `stepfun/${string}` | `volcano/${string}` | `volcengine/${string}`, UnSpeechOptions> & VoiceProviderWithExtraOptions<{
|
|
663
|
+
declare function createUnSpeech(apiKey: string, baseURL?: string): _xsai_ext_providers_utils0.SpeechProviderWithExtraOptions<`alibaba/${string}` | `aliyun/${string}` | `deepgram/${string}` | `elevenlabs/${string}` | `fishaudio/${string}` | `koemotion/${string}` | `minimax/${string}` | `openai/${string}` | `stepfun/${string}` | `volcano/${string}` | `volcengine/${string}`, UnSpeechOptions> & VoiceProviderWithExtraOptions<{
|
|
504
664
|
appId: string;
|
|
505
665
|
backend: "volcano";
|
|
506
666
|
} | {
|
|
@@ -510,7 +670,7 @@ declare function createUnSpeech(apiKey: string, baseURL?: string): _xsai_ext_pro
|
|
|
510
670
|
backend: "azure" | "microsoft";
|
|
511
671
|
region: MicrosoftRegions | string;
|
|
512
672
|
} | {
|
|
513
|
-
backend: "ali" | "alibaba" | "alibaba-model-studio" | "aliyun" | "bailian" | "deepgram" | "elevenlabs" | "koemotion" | "openai" | "step" | "stepfun";
|
|
673
|
+
backend: "ali" | "alibaba" | "alibaba-model-studio" | "aliyun" | "bailian" | "deepgram" | "elevenlabs" | "fish" | "fish-audio" | "fishaudio" | "koemotion" | "minimax" | "openai" | "step" | "stepfun";
|
|
514
674
|
}>;
|
|
515
675
|
//#endregion
|
|
516
676
|
//#region src/utils/generate-speech-response.d.ts
|
|
@@ -588,4 +748,4 @@ interface ListVoicesResponse {
|
|
|
588
748
|
}
|
|
589
749
|
declare function listVoices(options: ListVoicesOptions): Promise<Voice[]>;
|
|
590
750
|
//#endregion
|
|
591
|
-
export { DEFAULT_MICROSOFT_OUTPUT_FORMAT, GenerateSpeechResponseOptions, GenerateSpeechResponseResult, ListVoicesOptions, ListVoicesResponse, MicrosoftRegions, UnAlibabaCloudOptions, UnDeepgramOptions, UnElevenLabsOptions, UnMicrosoftOptionAutoSSML, UnMicrosoftOptionCommon, UnMicrosoftOptionCustomSSML, UnMicrosoftOptions, UnSpeechAPIError, UnSpeechAPIErrorOptions, UnSpeechOptions, UnStepfunOptions, UnVolcengineOptions, Voice, VoiceFormat, VoiceLanguage, VoiceProvider, VoiceProviderWithExtraOptions, buildMicrosoftSsml, createUnAlibabaCloud, createUnDeepgram, createUnElevenLabs, createUnMicrosoft, createUnSpeech, createUnStepfun, createUnVolcengine, escapeMicrosoftSsmlText, generateSpeechResponse, inferMicrosoftContentType, isMicrosoftVoiceId, listVoices, microsoftSpeedToProsodyRate, resolveMicrosoftOutputFormat };
|
|
751
|
+
export { DEFAULT_MICROSOFT_OUTPUT_FORMAT, GenerateSpeechResponseOptions, GenerateSpeechResponseResult, ListVoicesOptions, ListVoicesResponse, MicrosoftRegions, MinimaxModel, UnAlibabaCloudOptions, UnDeepgramOptions, UnElevenLabsOptions, UnFishAudioOptions, UnMicrosoftOptionAutoSSML, UnMicrosoftOptionCommon, UnMicrosoftOptionCustomSSML, UnMicrosoftOptions, UnMinimaxOptions, UnSpeechAPIError, UnSpeechAPIErrorOptions, UnSpeechOptions, UnStepfunOptions, UnVolcengineOptions, Voice, VoiceFormat, VoiceLanguage, VoiceProvider, VoiceProviderWithExtraOptions, buildMicrosoftSsml, createUnAlibabaCloud, createUnDeepgram, createUnElevenLabs, createUnFishAudio, createUnMicrosoft, createUnMinimax, createUnSpeech, createUnStepfun, createUnVolcengine, escapeMicrosoftSsmlText, generateSpeechResponse, inferMicrosoftContentType, isMicrosoftVoiceId, listVoices, microsoftSpeedToProsodyRate, resolveMicrosoftOutputFormat };
|
package/dist/index.mjs
CHANGED
|
@@ -279,6 +279,45 @@ function createUnMicrosoft(apiKey, baseURL = "http://localhost:5933/v1/") {
|
|
|
279
279
|
} });
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
+
//#endregion
|
|
283
|
+
//#region src/backend/minimax.ts
|
|
284
|
+
/**
|
|
285
|
+
* [MiniMax](https://platform.minimaxi.com/) provider for [UnSpeech](https://github.com/moeru-ai/unspeech)
|
|
286
|
+
*
|
|
287
|
+
* @param apiKey - MiniMax API Key
|
|
288
|
+
* @param baseURL - UnSpeech Instance URL
|
|
289
|
+
* @returns SpeechProviderWithExtraOptions & VoiceProviderWithExtraOptions
|
|
290
|
+
*/
|
|
291
|
+
function createUnMinimax(apiKey, baseURL = "http://localhost:5933/v1/") {
|
|
292
|
+
const toUnSpeechOptions = ({ speed, vol, pitch, emotion, stream, sampleRate, bitrate, format, channel }) => ({ extraBody: objCamelToSnake({
|
|
293
|
+
speed,
|
|
294
|
+
vol,
|
|
295
|
+
pitch,
|
|
296
|
+
emotion,
|
|
297
|
+
stream,
|
|
298
|
+
sampleRate,
|
|
299
|
+
bitrate,
|
|
300
|
+
format,
|
|
301
|
+
channel
|
|
302
|
+
}) });
|
|
303
|
+
return merge({ speech: (model, options) => ({
|
|
304
|
+
...options ? toUnSpeechOptions(options) : {},
|
|
305
|
+
apiKey,
|
|
306
|
+
baseURL,
|
|
307
|
+
model
|
|
308
|
+
}) }, { voice: (options) => {
|
|
309
|
+
let adjustedBaseURL = baseURL;
|
|
310
|
+
if (adjustedBaseURL.endsWith("v1/")) adjustedBaseURL = adjustedBaseURL.slice(0, -3);
|
|
311
|
+
else if (adjustedBaseURL.endsWith("v1")) adjustedBaseURL = adjustedBaseURL.slice(0, -2);
|
|
312
|
+
return {
|
|
313
|
+
query: "provider=minimax",
|
|
314
|
+
...options ? toUnSpeechOptions(options) : {},
|
|
315
|
+
apiKey,
|
|
316
|
+
baseURL: adjustedBaseURL
|
|
317
|
+
};
|
|
318
|
+
} });
|
|
319
|
+
}
|
|
320
|
+
|
|
282
321
|
//#endregion
|
|
283
322
|
//#region src/backend/volcengine.ts
|
|
284
323
|
/**
|
|
@@ -448,4 +487,4 @@ async function listVoices(options) {
|
|
|
448
487
|
}
|
|
449
488
|
|
|
450
489
|
//#endregion
|
|
451
|
-
export { UnSpeechAPIError, buildMicrosoftSsml, createUnAlibabaCloud, createUnDeepgram, createUnElevenLabs, createUnMicrosoft, createUnSpeech, createUnVolcengine, escapeMicrosoftSsmlText, generateSpeechResponse, inferMicrosoftContentType, isMicrosoftVoiceId, listVoices, microsoftSpeedToProsodyRate, resolveMicrosoftOutputFormat };
|
|
490
|
+
export { UnSpeechAPIError, buildMicrosoftSsml, createUnAlibabaCloud, createUnDeepgram, createUnElevenLabs, createUnMicrosoft, createUnMinimax, createUnSpeech, createUnVolcengine, escapeMicrosoftSsmlText, generateSpeechResponse, inferMicrosoftContentType, isMicrosoftVoiceId, listVoices, microsoftSpeedToProsodyRate, resolveMicrosoftOutputFormat };
|