unspeech 0.1.14 → 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 +207 -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,6 +353,210 @@ 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
|
|
500
|
+
//#region src/backend/stepfun.d.ts
|
|
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;
|
|
518
|
+
/**
|
|
519
|
+
* Audio volume. Range: 0.1 to 2.0.
|
|
520
|
+
*
|
|
521
|
+
* @default 1
|
|
522
|
+
*/
|
|
523
|
+
volume?: number;
|
|
524
|
+
/**
|
|
525
|
+
* Voice labels for `step-tts-2` and `step-tts-mini`.
|
|
526
|
+
*
|
|
527
|
+
* Not supported by `stepaudio-2.5-tts`; use `instruction` instead.
|
|
528
|
+
*/
|
|
529
|
+
voiceLabel?: {
|
|
530
|
+
language?: '粤语' | '四川话' | '日语' | string;
|
|
531
|
+
emotion?: string;
|
|
532
|
+
style?: string;
|
|
533
|
+
};
|
|
534
|
+
/**
|
|
535
|
+
* Global natural-language guidance for `stepaudio-2.5-tts`.
|
|
536
|
+
*/
|
|
537
|
+
instruction?: string;
|
|
538
|
+
/**
|
|
539
|
+
* Output sample rate.
|
|
540
|
+
*
|
|
541
|
+
* @default 24000
|
|
542
|
+
*/
|
|
543
|
+
sampleRate?: 8000 | 16000 | 22050 | 24000 | 48000 | number;
|
|
544
|
+
pronunciationMap?: {
|
|
545
|
+
tone: string[];
|
|
546
|
+
};
|
|
547
|
+
streamFormat?: 'audio' | 'sse';
|
|
548
|
+
markdownFilter?: boolean;
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* [StepFun / 阶跃星辰](https://platform.stepfun.com/) provider for
|
|
552
|
+
* [UnSpeech](https://github.com/moeru-ai/unspeech).
|
|
553
|
+
*
|
|
554
|
+
* @param apiKey - StepFun API key
|
|
555
|
+
* @param baseURL - UnSpeech Instance URL
|
|
556
|
+
* @returns SpeechProviderWithExtraOptions
|
|
557
|
+
*/
|
|
558
|
+
declare function createUnStepfun(apiKey: string, baseURL?: string): SpeechProviderWithExtraOptions<`stepfun/${string}`, UnStepfunOptions> & VoiceProviderWithExtraOptions<UnStepfunOptions>;
|
|
559
|
+
//#endregion
|
|
356
560
|
//#region src/backend/volcengine.d.ts
|
|
357
561
|
interface UnVolcengineOptions {
|
|
358
562
|
app?: {
|
|
@@ -456,7 +660,7 @@ declare function createUnVolcengine(apiKey: string, baseURL?: string): SpeechPro
|
|
|
456
660
|
//#endregion
|
|
457
661
|
//#region src/backend/index.d.ts
|
|
458
662
|
/** @see {@link https://github.com/moeru-ai/unspeech} */
|
|
459
|
-
declare function createUnSpeech(apiKey: string, baseURL?: string): _xsai_ext_providers_utils0.SpeechProviderWithExtraOptions<`alibaba/${string}` | `aliyun/${string}` | `deepgram/${string}` | `elevenlabs/${string}` | `koemotion/${string}` | `openai/${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<{
|
|
460
664
|
appId: string;
|
|
461
665
|
backend: "volcano";
|
|
462
666
|
} | {
|
|
@@ -466,7 +670,7 @@ declare function createUnSpeech(apiKey: string, baseURL?: string): _xsai_ext_pro
|
|
|
466
670
|
backend: "azure" | "microsoft";
|
|
467
671
|
region: MicrosoftRegions | string;
|
|
468
672
|
} | {
|
|
469
|
-
backend: "ali" | "alibaba" | "alibaba-model-studio" | "aliyun" | "bailian" | "deepgram" | "elevenlabs" | "koemotion" | "openai";
|
|
673
|
+
backend: "ali" | "alibaba" | "alibaba-model-studio" | "aliyun" | "bailian" | "deepgram" | "elevenlabs" | "fish" | "fish-audio" | "fishaudio" | "koemotion" | "minimax" | "openai" | "step" | "stepfun";
|
|
470
674
|
}>;
|
|
471
675
|
//#endregion
|
|
472
676
|
//#region src/utils/generate-speech-response.d.ts
|
|
@@ -544,4 +748,4 @@ interface ListVoicesResponse {
|
|
|
544
748
|
}
|
|
545
749
|
declare function listVoices(options: ListVoicesOptions): Promise<Voice[]>;
|
|
546
750
|
//#endregion
|
|
547
|
-
export { DEFAULT_MICROSOFT_OUTPUT_FORMAT, GenerateSpeechResponseOptions, GenerateSpeechResponseResult, ListVoicesOptions, ListVoicesResponse, MicrosoftRegions, UnAlibabaCloudOptions, UnDeepgramOptions, UnElevenLabsOptions, UnMicrosoftOptionAutoSSML, UnMicrosoftOptionCommon, UnMicrosoftOptionCustomSSML, UnMicrosoftOptions, UnSpeechAPIError, UnSpeechAPIErrorOptions, UnSpeechOptions, UnVolcengineOptions, Voice, VoiceFormat, VoiceLanguage, VoiceProvider, VoiceProviderWithExtraOptions, buildMicrosoftSsml, createUnAlibabaCloud, createUnDeepgram, createUnElevenLabs, createUnMicrosoft, createUnSpeech, 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 };
|