dsh-audiogen 0.4.22 → 0.4.24
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 -2
- package/README.zh-CN.md +2 -2
- package/lib/client.js +497 -414
- package/lib/client.js.map +1 -1
- package/lib/index.js +94 -14
- package/package.json +22 -20
- package/skills/sfx/SKILL.md +7 -3
- package/src/agent-audio-tools.ts +3 -3
- package/src/audio-engine.ts +74 -0
- package/src/client/SettingsCard.tsx +2 -1
- package/src/client/audio-toolview.tsx +5 -14
- package/src/client/channels-form.ts +1 -1
- package/src/client/field-specs.ts +56 -4
- package/src/client/index.ts +2 -20
- package/src/client/settings-form.ts +2 -1
- package/src/client/settings-scope.ts +10 -9
- package/src/client/studio-view.tsx +21 -10
- package/src/index.ts +11 -10
- package/src/protocol.ts +4 -4
- package/src/routes.ts +2 -2
|
@@ -8,12 +8,8 @@
|
|
|
8
8
|
* uses, self-contained per plugin.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
type SettingsScope,
|
|
14
|
-
type SettingsScopeSnapshot,
|
|
15
|
-
type SnapshotStore,
|
|
16
|
-
} from '@deepseek-ai/dsh-client-runtime/client'
|
|
11
|
+
import { createSnapshotStore, type SnapshotStore } from '@deepseek-ai/dsh-client-store'
|
|
12
|
+
import type { SettingsScope, SettingsScopeSnapshot } from '@deepseek-ai/dsh-client-ui-settings/client'
|
|
17
13
|
import { SETTINGS_API, type AudioModelCategory, type ChannelConfig } from '../protocol.ts'
|
|
18
14
|
|
|
19
15
|
/** The fields this plugin's settings card edits. */
|
|
@@ -156,6 +152,11 @@ class BridgeScopeController<T> implements SettingsScope<T> {
|
|
|
156
152
|
return this.enqueue(() => this.writeOps([{ op: 'unset', path: [field] }]))
|
|
157
153
|
}
|
|
158
154
|
|
|
155
|
+
/** Official SettingsScope mutation entry: several path ops in one revision-fenced mutate call. */
|
|
156
|
+
mutate(ops: readonly SettingsOp[], expectedRevision?: number): Promise<void> {
|
|
157
|
+
return this.enqueue(() => this.writeOps(ops, expectedRevision))
|
|
158
|
+
}
|
|
159
|
+
|
|
159
160
|
/** Apply several path ops in one revision-fenced mutate call (atomic save).
|
|
160
161
|
* Path ops may address plain-object fields (e.g. `channelSecrets.<id>`),
|
|
161
162
|
* but never navigate *inside* arrays — write array fields wholesale. */
|
|
@@ -204,13 +205,13 @@ class BridgeScopeController<T> implements SettingsScope<T> {
|
|
|
204
205
|
this.accept(view, writable)
|
|
205
206
|
}
|
|
206
207
|
|
|
207
|
-
private async writeOps(ops: SettingsOp[]): Promise<void> {
|
|
208
|
-
const revision = this.getSnapshot().revision
|
|
208
|
+
private async writeOps(ops: readonly SettingsOp[], expectedRevision?: number): Promise<void> {
|
|
209
|
+
const revision = expectedRevision ?? this.getSnapshot().revision
|
|
209
210
|
let response
|
|
210
211
|
try {
|
|
211
212
|
response = await this.api.mutate({
|
|
212
213
|
ns: this.spec.namespace,
|
|
213
|
-
ops,
|
|
214
|
+
ops: [...ops],
|
|
214
215
|
...revision === undefined ? {} : { expectedRevision: revision },
|
|
215
216
|
})
|
|
216
217
|
} catch {
|
|
@@ -10,7 +10,7 @@ import { useEffect, useMemo, useRef, useState } from 'react'
|
|
|
10
10
|
import type { AudiogenApi } from './api.ts'
|
|
11
11
|
import type { AudiogenConfig, AudiogenScope } from './settings-scope.ts'
|
|
12
12
|
import { audioModelOptions } from './settings-scope.ts'
|
|
13
|
-
import { globalFieldSpecs, overrideRowSpecs, presetLabel, type FieldSpec } from './field-specs.ts'
|
|
13
|
+
import { globalFieldSpecs, overrideRowSpecs, presetLabel, fieldOptionsFor, type FieldSpec } from './field-specs.ts'
|
|
14
14
|
import { tt } from './helpers.ts'
|
|
15
15
|
import {
|
|
16
16
|
HISTORY_API,
|
|
@@ -87,7 +87,7 @@ function overrideSpread(override: Record<string, string>): Partial<GenerateAudio
|
|
|
87
87
|
if (speed !== undefined) out.speed = speed
|
|
88
88
|
const emotion = (override.emotion ?? '').trim()
|
|
89
89
|
if (emotion !== '') out.emotion = emotion
|
|
90
|
-
const sampleRate = num('
|
|
90
|
+
const sampleRate = num('sampleRate')
|
|
91
91
|
if (sampleRate !== undefined) out.sampleRate = sampleRate
|
|
92
92
|
const bitrate = num('bitrate')
|
|
93
93
|
if (bitrate !== undefined) out.bitrate = bitrate
|
|
@@ -97,7 +97,7 @@ function overrideSpread(override: Record<string, string>): Partial<GenerateAudio
|
|
|
97
97
|
if (seed !== undefined) out.seed = seed
|
|
98
98
|
const steps = num('steps')
|
|
99
99
|
if (steps !== undefined) out.steps = steps
|
|
100
|
-
const cfgScale = num('
|
|
100
|
+
const cfgScale = num('cfgScale')
|
|
101
101
|
if (cfgScale !== undefined) out.cfgScale = cfgScale
|
|
102
102
|
return out
|
|
103
103
|
}
|
|
@@ -443,6 +443,17 @@ export function StudioView(props: {
|
|
|
443
443
|
// 按(模式 × 渠道集合)计算全局字段:对比模式只留共有字段,独有字段在覆盖矩阵中。
|
|
444
444
|
const globalSpecs = useMemo(() => globalFieldSpecs(mode, fieldPresets), [mode, fieldPresets])
|
|
445
445
|
|
|
446
|
+
// ElevenLabs 音效:格式为 pcm/ulaw/alaw 时无码率、ulaw/alaw 仅 8000Hz——按所选格式隐藏不适用的参数,避免组合出非法 output_format。
|
|
447
|
+
const effectiveSpecs = useMemo(() => {
|
|
448
|
+
if (mode !== 'sfx') return globalSpecs
|
|
449
|
+
const elevenOnly = fieldPresets.length > 0 && fieldPresets.every(preset => preset.toLowerCase() === 'elevenlabs')
|
|
450
|
+
if (!elevenOnly) return globalSpecs
|
|
451
|
+
const codec = format.trim().toLowerCase()
|
|
452
|
+
if (codec === 'ulaw' || codec === 'alaw') return globalSpecs.filter(spec => spec.key !== 'sampleRate' && spec.key !== 'bitrate')
|
|
453
|
+
if (codec === 'pcm') return globalSpecs.filter(spec => spec.key !== 'bitrate')
|
|
454
|
+
return globalSpecs
|
|
455
|
+
}, [mode, fieldPresets, format, globalSpecs])
|
|
456
|
+
|
|
446
457
|
// 模型下拉按渠道分组。
|
|
447
458
|
const groupedModels = useMemo(() => {
|
|
448
459
|
const groups: Array<{ channelId: string; channelName: string; models: Array<{ alias: string }> }> = []
|
|
@@ -891,7 +902,7 @@ export function StudioView(props: {
|
|
|
891
902
|
<label className={css.label} key={spec.key} title={spec.hint}>
|
|
892
903
|
<span>{spec.label}</span>
|
|
893
904
|
<select className={css.input} value={sampleRate} onChange={event => setSampleRate(event.target.value)}>
|
|
894
|
-
<option value=""
|
|
905
|
+
<option value="">{spec.placeholder ?? '默认'}</option>
|
|
895
906
|
{(spec.options ?? []).map(option => <option key={option} value={option}>{option}</option>)}
|
|
896
907
|
</select>
|
|
897
908
|
</label>
|
|
@@ -901,7 +912,7 @@ export function StudioView(props: {
|
|
|
901
912
|
<label className={css.label} key={spec.key} title={spec.hint}>
|
|
902
913
|
<span>{spec.label}</span>
|
|
903
914
|
<select className={css.input} value={bitrate} onChange={event => setBitrate(event.target.value)}>
|
|
904
|
-
<option value=""
|
|
915
|
+
<option value="">{spec.placeholder ?? '默认'}</option>
|
|
905
916
|
{(spec.options ?? []).map(option => <option key={option} value={option}>{option}</option>)}
|
|
906
917
|
</select>
|
|
907
918
|
</label>
|
|
@@ -1249,7 +1260,7 @@ export function StudioView(props: {
|
|
|
1249
1260
|
}))
|
|
1250
1261
|
}}>
|
|
1251
1262
|
<option value="">自动</option>
|
|
1252
|
-
{row.options
|
|
1263
|
+
{(fieldOptionsFor(row.key, entry.preset, mode) ?? row.options ?? []).map(option => <option key={option} value={option}>{option}</option>)}
|
|
1253
1264
|
</select>
|
|
1254
1265
|
) : (
|
|
1255
1266
|
<input
|
|
@@ -1292,19 +1303,19 @@ export function StudioView(props: {
|
|
|
1292
1303
|
)
|
|
1293
1304
|
) : null}
|
|
1294
1305
|
|
|
1295
|
-
{
|
|
1306
|
+
{effectiveSpecs.some(spec => spec.advanced !== true) ? <p className={css.formSection}>生成参数</p> : null}
|
|
1296
1307
|
<div className={css.formFields}>
|
|
1297
|
-
{
|
|
1308
|
+
{effectiveSpecs.filter(spec => spec.advanced !== true).map(spec => (
|
|
1298
1309
|
<div key={spec.key} className={spec.key === 'lyrics' || spec.key === 'toneText' ? css.fieldFull : css.fieldCell}>
|
|
1299
1310
|
{renderField(spec)}
|
|
1300
1311
|
</div>
|
|
1301
1312
|
))}
|
|
1302
1313
|
</div>
|
|
1303
1314
|
|
|
1304
|
-
{mode === 'tts' &&
|
|
1315
|
+
{mode === 'tts' && effectiveSpecs.some(spec => spec.advanced === true) ? (
|
|
1305
1316
|
<details className={css.advanced}>
|
|
1306
1317
|
<summary>MiniMax 高级参数</summary>
|
|
1307
|
-
{
|
|
1318
|
+
{effectiveSpecs.filter(spec => spec.advanced === true).map(spec => renderField(spec))}
|
|
1308
1319
|
</details>
|
|
1309
1320
|
) : null}
|
|
1310
1321
|
|
package/src/index.ts
CHANGED
|
@@ -8,11 +8,10 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import type { Context } from '@deepseek-ai/cordis'
|
|
11
|
-
import { installSettingsSection, settingsNamespace } from '@deepseek-ai/dsh-settings'
|
|
12
11
|
import { existsSync, mkdirSync, readdirSync, copyFileSync } from 'node:fs'
|
|
13
12
|
import { fileURLToPath } from 'node:url'
|
|
14
13
|
import { dirname, join } from 'node:path'
|
|
15
|
-
import z from 'schemastery'
|
|
14
|
+
import z from '@deepseek-ai/schemastery'
|
|
16
15
|
import type {} from '@deepseek-ai/dsh-host-webserver'
|
|
17
16
|
import type {} from '@deepseek-ai/dsh-system-prompt'
|
|
18
17
|
import type {} from '@deepseek-ai/dsh-tools'
|
|
@@ -33,8 +32,8 @@ export const name = 'audiogen'
|
|
|
33
32
|
/** Services required before the surfaces can mount. */
|
|
34
33
|
export const inject = ['webServer', 'systemPrompt']
|
|
35
34
|
|
|
36
|
-
/** The
|
|
37
|
-
export const AudioGenSettingsNamespace =
|
|
35
|
+
/** The settings namespace of this plugin. */
|
|
36
|
+
export const AudioGenSettingsNamespace = AUDIOGEN_SETTINGS_NAMESPACE
|
|
38
37
|
|
|
39
38
|
export interface Config {
|
|
40
39
|
enabled?: boolean
|
|
@@ -323,12 +322,14 @@ export function apply(ctx: Context, config?: Config): void {
|
|
|
323
322
|
})
|
|
324
323
|
}
|
|
325
324
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
325
|
+
ctx.inject(['settings'], (settingsCtx) => {
|
|
326
|
+
settingsCtx.settings.installSection(ctx, AudioGenSettingsNamespace, Config, config ?? {}, {
|
|
327
|
+
setSource: (source) => {
|
|
328
|
+
current = source
|
|
329
|
+
sync()
|
|
330
|
+
},
|
|
331
|
+
onChange: sync,
|
|
332
|
+
})
|
|
332
333
|
})
|
|
333
334
|
|
|
334
335
|
sync()
|
package/src/protocol.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
export const AUDIOGEN_SETTINGS_NAMESPACE = 'dsh-audiogen'
|
|
9
9
|
|
|
10
10
|
/** Published package version shared by the host updater and the client UI. */
|
|
11
|
-
export const PLUGIN_VERSION = '0.4.
|
|
11
|
+
export const PLUGIN_VERSION = '0.4.24'
|
|
12
12
|
|
|
13
13
|
/** Same-origin route family (loopback-only, mirroring dsh-imagegen). */
|
|
14
14
|
export const SETTINGS_API = {
|
|
@@ -283,7 +283,7 @@ export interface GenerateAudioRequest {
|
|
|
283
283
|
steps?: number
|
|
284
284
|
/** Stable Audio 提示词遵循度(cfg_scale 1-25;stable-audio-2 默认 7,2.5/3 默认 1)。 */
|
|
285
285
|
cfgScale?: number
|
|
286
|
-
/** Output format
|
|
286
|
+
/** Output format. MiniMax mp3/wav/pcm; ElevenLabs 音效为编码名 mp3/pcm/ulaw/alaw/opus(与采样率、码率组合为 output_format)。 */
|
|
287
287
|
format?: string
|
|
288
288
|
/** Channel this request targets (host falls back to default). */
|
|
289
289
|
channelId?: string
|
|
@@ -307,9 +307,9 @@ export interface GenerateAudioRequest {
|
|
|
307
307
|
latexRead?: boolean
|
|
308
308
|
/** MiniMax 发音词典 tone 条目,元素形如 "处理/(chu3)(li3)" 或 "危险/dangerous"。 */
|
|
309
309
|
pronunciationTone?: string[]
|
|
310
|
-
/** MiniMax 采样率:16000/24000/32000
|
|
310
|
+
/** MiniMax 采样率:16000/24000/32000/44100,默认 32000(audio_setting.sample_rate);ElevenLabs 音效为 8000-48000(与格式/码率组合为 output_format)。 */
|
|
311
311
|
sampleRate?: number
|
|
312
|
-
/** MiniMax 码率(bps):64000-320000,默认 128000
|
|
312
|
+
/** MiniMax 码率(bps):64000-320000,默认 128000;ElevenLabs 音效码率(kbps):32/48/64/96/128/192(与格式/采样率组合为 output_format)。 */
|
|
313
313
|
bitrate?: number
|
|
314
314
|
/** MiniMax 声道数:1 或 2,默认 1。 */
|
|
315
315
|
audioChannel?: number
|
package/src/routes.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import type { IncomingMessage, ServerResponse } from 'node:http'
|
|
10
10
|
import { randomUUID } from 'node:crypto'
|
|
11
11
|
import type { WebRoute } from '@deepseek-ai/dsh-host-webserver'
|
|
12
|
-
import { SettingsConflictError,
|
|
12
|
+
import { SettingsConflictError, type SettingsDescriptor } from '@deepseek-ai/dsh-settings'
|
|
13
13
|
import { generateAudio, AudioGenError, type AudioChannel } from './audio-engine.ts'
|
|
14
14
|
import { listVendorVoices, listVendorVoicesWithFallback, deleteVendorVoice, type ListVoicesOptions, type VendorVoiceEntry } from './voice-manager.ts'
|
|
15
15
|
import { recommendVoices, type VoiceRecommendation } from './voice-recommend.ts'
|
|
@@ -636,7 +636,7 @@ export function makeRoutes(deps: AudiogenRoutesDeps): WebRoute[] { const guard
|
|
|
636
636
|
}
|
|
637
637
|
const expectedRevision = typeof body.expectedRevision === 'number' ? body.expectedRevision : undefined
|
|
638
638
|
try {
|
|
639
|
-
await deps.settings.mutate(
|
|
639
|
+
await deps.settings.mutate(ns, body.ops, expectedRevision)
|
|
640
640
|
} catch (error) {
|
|
641
641
|
writeJson(res, 200, failureOf(error))
|
|
642
642
|
return
|