Skip to content

Commit 3631a58

Browse files
committed
fix(sdk/typescript): lint & disable @masknet/unicode-specific-set
1 parent 99d532d commit 3631a58

File tree

5 files changed

+82
-82
lines changed

5 files changed

+82
-82
lines changed

sdk/typescript/eslint.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export default antfu({ typescript: { tsconfigPath: './tsconfig.json' } })
1818
rules: {
1919
'@masknet/no-default-error': 'off',
2020
'@masknet/no-then': 'off',
21+
'@masknet/unicode-specific-set': 'off',
2122
'sonarjs/todo-tag': 'warn',
2223
},
2324
})

sdk/typescript/src/backend/alibabacloud.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ import { objCamelToSnake } from '@xsai/shared'
66
import type { UnSpeechOptions, VoiceProviderWithExtraOptions } from '../types'
77

88
export interface UnAlibabaCloudOptions {
9+
/**
10+
* Speech pitch. Range: 0.5 to 2.0.
11+
* @default 1.0
12+
*/
13+
pitch?: number
14+
/**
15+
* Speech rate. Range: 0.5 to 2.0.
16+
* @default 1.0
17+
*/
18+
rate?: number
919
/**
1020
* Sampling rate of the synthesized audio.
1121
* @default 22050
@@ -16,16 +26,6 @@ export interface UnAlibabaCloudOptions {
1626
* @default 50
1727
*/
1828
volume?: number
19-
/**
20-
* Speech rate. Range: 0.5 to 2.0.
21-
* @default 1.0
22-
*/
23-
rate?: number
24-
/**
25-
* Speech pitch. Range: 0.5 to 2.0.
26-
* @default 1.0
27-
*/
28-
pitch?: number
2929
}
3030

3131
/**
@@ -42,13 +42,13 @@ export interface UnAlibabaCloudOptions {
4242
*/
4343
export const createUnAlibabaCloud = (apiKey: string, baseURL = 'http://localhost:5933/v1/') => {
4444
const toUnSpeechOptions = (options: UnAlibabaCloudOptions): UnSpeechOptions => {
45-
const { sampleRate, volume, rate, pitch } = options
45+
const { pitch, rate, sampleRate, volume } = options
4646

4747
const extraBody: Record<string, unknown> = {
48+
pitch,
49+
rate,
4850
sampleRate,
4951
volume,
50-
rate,
51-
pitch,
5252
}
5353

5454
// Remove undefined values before converting keys

sdk/typescript/src/backend/elevenlabs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export const createUnElevenLabs = (apiKey: string, baseURL = 'http://localhost:5
171171
}
172172

173173
return {
174-
query: `provider=elevenlabs`,
174+
query: 'provider=elevenlabs',
175175
...(options ? toUnSpeechOptions(options) : {}),
176176
apiKey,
177177
baseURL,
Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
import { createSpeechProviderWithExtraOptions, merge } from '@xsai-ext/shared-providers'
22

3-
import { MicrosoftRegions } from './microsoft'
4-
import { UnSpeechOptions, VoiceProviderWithExtraOptions } from '../types'
3+
import type { UnSpeechOptions, VoiceProviderWithExtraOptions } from '../types'
4+
import type { MicrosoftRegions } from './microsoft'
55

6+
export * from './alibabacloud'
67
export * from './elevenlabs'
78
export * from './microsoft'
89
export * from './volcengine'
9-
export * from './alibabacloud'
1010

1111
/** @see {@link https://github.com/moeru-ai/unspeech} */
1212
export const createUnSpeech = (apiKey: string, baseURL = 'http://localhost:5933/v1/') => {
1313
const voiceProvider: VoiceProviderWithExtraOptions<
1414
{
15-
backend:
16-
| 'elevenlabs'
17-
| 'koemotion'
18-
| 'openai'
19-
| 'alibaba' | 'aliyun' | 'ali' | 'bailian' | 'alibaba-model-studio'
20-
} | {
21-
backend: 'microsoft' | 'azure'
22-
region: MicrosoftRegions | string
23-
} | {
24-
backend: 'volcengine'
25-
appId: string
26-
} | {
27-
backend: 'volcano'
28-
appId: string
29-
}
15+
appId: string
16+
backend: 'volcano'
17+
} | {
18+
appId: string
19+
backend: 'volcengine'
20+
} | {
21+
backend: 'azure' | 'microsoft'
22+
region: MicrosoftRegions | string
23+
} | {
24+
backend:
25+
| 'ali'
26+
| 'alibaba'
27+
| 'alibaba-model-studio'
28+
| 'aliyun' | 'bailian' | 'elevenlabs' | 'koemotion' | 'openai'
29+
}
3030
> = {
3131
voice: (options) => {
3232
if (baseURL.endsWith('v1/')) {
@@ -38,31 +38,31 @@ export const createUnSpeech = (apiKey: string, baseURL = 'http://localhost:5933/
3838

3939
if (options?.backend === 'microsoft' || options?.backend === 'azure') {
4040
return {
41-
query: `region=${options.region}&provider=${options.backend}`,
42-
baseURL,
4341
apiKey,
42+
baseURL,
43+
query: `region=${options.region}&provider=${options.backend}`,
4444
}
4545
}
4646

4747
return {
48-
query: `provider=${options?.backend}`,
49-
baseURL,
5048
apiKey,
49+
baseURL,
50+
query: `provider=${options?.backend}`,
5151
}
5252
},
5353
}
5454

5555
return merge(
56-
createSpeechProviderWithExtraOptions<
57-
| `elevenlabs/${string}`
58-
| `koemotion/${string}`
59-
| `openai/${string}`
60-
| `volcengine/${string}`
61-
| `volcano/${string}`
62-
| `aliyun/${string}`
63-
| `alibaba/${string}`,
56+
createSpeechProviderWithExtraOptions<
57+
| `alibaba/${string}`
58+
| `aliyun/${string}`
59+
| `elevenlabs/${string}`
60+
| `koemotion/${string}`
61+
| `openai/${string}`
62+
| `volcano/${string}`
63+
| `volcengine/${string}`,
6464
UnSpeechOptions
6565
>({ apiKey, baseURL }),
66-
voiceProvider
66+
voiceProvider,
6767
)
6868
}

sdk/typescript/src/backend/volcengine.ts

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@ import type { UnSpeechOptions, VoiceProviderWithExtraOptions } from '../types'
88
export interface UnVolcengineOptions {
99
app?: {
1010
appId?: string
11-
cluster?: string | 'volcano_tts'
12-
}
13-
user?: {
14-
uid?: string
11+
cluster?: 'volcano_tts' | string
1512
}
1613
audio?: {
17-
emotion?: string | 'angry'
18-
enableEmotion?: boolean
14+
/**
15+
* @default 160
16+
*/
17+
bitRate?: 160 | number
18+
/**
19+
* Languages that contextual to the model
20+
*/
21+
contextLanguage?: 'es' | 'id' | 'pt' | string
22+
emotion?: 'angry' | string
1923
/**
2024
* After calling emotion to set the emotion parameter you can use emotion_scale to
2125
* further set the emotion value, the range is 1~5, the default value is 4 when not
@@ -31,24 +35,11 @@ export interface UnVolcengineOptions {
3135
* @default 4
3236
*/
3337
emotionScale?: number
38+
enableEmotion?: boolean
3439
/**
3540
* @default 'mp3'
3641
*/
37-
encoding?: 'wav' | 'pcm' | 'ogg_opus' | 'mp3'
38-
/**
39-
* 0.8~2
40-
*
41-
* @default 1
42-
*/
43-
speedRatio?: number
44-
/**
45-
* @default 24000
46-
*/
47-
rate?: number | 24000 | 8000 | 16000
48-
/**
49-
* @default 160
50-
*/
51-
bitRate?: number | 160
42+
encoding?: 'mp3' | 'ogg_opus' | 'pcm' | 'wav'
5243
/**
5344
* - undefined: General mixed bilingual
5445
* - crosslingual: mix with zh/en/ja/es-ms/id/pt-br
@@ -61,34 +52,43 @@ export interface UnVolcengineOptions {
6152
*
6253
* @default 'en'
6354
*/
64-
explicitLanguage?: string | 'crosslingual' | 'zh' | 'en' | 'jp' | 'es-mx' | 'id' | 'pt-br'
65-
/**
66-
* Languages that contextual to the model
67-
*/
68-
contextLanguage?: string | 'id' | 'es' | 'pt'
55+
explicitLanguage?: 'crosslingual' | 'en' | 'es-mx' | 'id' | 'jp' | 'pt-br' | 'zh' | string
6956
/**
7057
* 0.5 ~ 2
7158
*
7259
* @default 1
7360
*/
7461
loudnessRatio?: number
62+
/**
63+
* @default 24000
64+
*/
65+
rate?: 8000 | 16000 | 24000 | number
66+
/**
67+
* 0.8~2
68+
*
69+
* @default 1
70+
*/
71+
speedRatio?: number
7572
}
7673
request?: {
74+
cacheConfig?: Record<string, unknown>
75+
disableMarkdownFilter?: boolean
76+
enableLatexTone?: boolean
77+
extraParam?: string
7778
reqid?: string
78-
/**
79-
* - set to `ssml` to use SSML
80-
*/
81-
textType?: string | 'ssml'
8279
/**
8380
* 0 ~ 30000ms
8481
*/
8582
silenceDuration?: number
86-
withTimestamp?: string
87-
extraParam?: string
88-
disableMarkdownFilter?: boolean
89-
enableLatexTone?: boolean
90-
cacheConfig?: Record<string, unknown>
83+
/**
84+
* - set to `ssml` to use SSML
85+
*/
86+
textType?: 'ssml' | string
9187
useCache?: boolean
88+
withTimestamp?: string
89+
}
90+
user?: {
91+
uid?: string
9292
}
9393
}
9494

@@ -101,7 +101,6 @@ export interface UnVolcengineOptions {
101101
* as ElevenLabs, Azure TTS, Google TTS, etc.
102102
*
103103
* @param apiKey - Volcano Engine Speech Service Token
104-
* @param appId - Volcano Engine Speech Service App ID
105104
* @param baseURL - UnSpeech Instance URL
106105
* @returns SpeechProviderWithExtraOptions
107106
*/
@@ -156,7 +155,7 @@ export const createUnVolcengine = (apiKey: string, baseURL = 'http://localhost:5
156155
}
157156

158157
return {
159-
query: `provider=volcengine`,
158+
query: 'provider=volcengine',
160159
...(options ? toUnSpeechOptions(options) : {}),
161160
apiKey,
162161
baseURL,

0 commit comments

Comments
 (0)