mirror of
https://github.com/nexu-io/openmotion.git
synced 2026-12-02 02:21:02 +08:00
* feat(sound-studio): redesign waveforms, live playback flow, voice cards and audio track library - Extract real 128-bucket PCM audio waveforms with noise gating and smoothing on probe and playback decode - Redesign Sound Studio waveforms into pixel-crisp 1:1 SVG bars with generous horizontal breathing room, pointer-capture drag scrubbing, monochrome played progress, accent needle, and 60/120fps direct-DOM living playback flow - Redesign Speech voice selector into clean typographic studio cards with authentic localized timbre traits, isolated inline auditioning, balanced featured grids for large catalogs, and single-column layout for single-voice models - Refine Audio track library filtering, server-side audioKind queries, voice metadata display, overflow actions, and bottom player dock polish across dark and light themes * fix(sound-studio): preserve cross-tab starter drafts and persist resolved audioKind - Route Music, SFX, and Speech starter Use actions through selectSoundTab/reuseInScene with the target draft and resolved SFX model parameters so draftKey transitions never drop prompts or SFX settings - Persist resolved audioKind on audio AssetVersion records during generation (using model id, mode, modelId, and label) and uploads, keeping id-only inference as legacy fallback across gateway filtering and Sound Studio UI - Add regression tests covering cross-tab starter handoff and opaque model ID audioKind classification * fix(sound-studio): split structured vs advanced JSON params on draftKey transitions - Split persisted or cross-tab draft.parameters via parameterDraftFromParams using the model's structured generationOptions fields so schema-less BYOK raw JSON keys stay in advanced and never leak into ParameterDraft.values - Seed parameterDrafts once per draftKey transition rather than on local SoundComposer handleParamChange updates - Add regression test verifying editing and clearing raw JSON on a schema-less BYOK audio model --------- Co-authored-by: bone3deep1962-collab <bone3deep1962@gmail.com>
49 lines
2.1 KiB
TypeScript
49 lines
2.1 KiB
TypeScript
export type AudioKind = 'music' | 'sfx' | 'speech' | 'upload';
|
||
|
||
export const AUDIO_KINDS: readonly AudioKind[] = ['music', 'sfx', 'speech', 'upload'];
|
||
|
||
export function isAudioKind(value: unknown): value is AudioKind {
|
||
return typeof value === 'string' && (AUDIO_KINDS as readonly string[]).includes(value);
|
||
}
|
||
|
||
/** Identify dedicated sound-effects / foley endpoints without misclassifying music generators. */
|
||
export function isSfxModelText(text: string): boolean {
|
||
return /sound[-_ ]?effects?|\bsfx\b|foley|audio[-_ ]?effects?/i.test(text);
|
||
}
|
||
|
||
/** Shared audio domain classifier used by both server-side persistence/filtering and Sound Studio UI. */
|
||
export function classifyAudioKind(modelId?: string, mode?: string, source?: string, label?: string): AudioKind {
|
||
if (source === 'upload' || !modelId) return 'upload';
|
||
if (mode === 'text-to-speech') return 'speech';
|
||
const combined = label ? `${modelId} ${label}` : modelId;
|
||
if (isSfxModelText(combined)) return 'sfx';
|
||
if (/tts|speech|kokoro|voice|elevenlabs-v3/i.test(modelId)) return 'speech';
|
||
return 'music';
|
||
}
|
||
|
||
/** Derive a compact readable display title from long narration scripts or prompts. */
|
||
export function audioAssetTitle(prompt: string, maxChars = 32): string {
|
||
const normalized = prompt.replace(/\s+/g, ' ').trim();
|
||
if (!normalized) return 'Audio';
|
||
if (normalized.length <= maxChars) return normalized;
|
||
const slice = normalized.slice(0, maxChars);
|
||
// Prefer ending on a sentence boundary when one occurs in the second half.
|
||
const sentenceBreak = Math.max(
|
||
slice.lastIndexOf('。'),
|
||
slice.lastIndexOf('!'),
|
||
slice.lastIndexOf('?'),
|
||
slice.lastIndexOf('. '),
|
||
slice.lastIndexOf('! '),
|
||
slice.lastIndexOf('? '),
|
||
);
|
||
if (sentenceBreak >= Math.floor(maxChars * 0.45)) {
|
||
return slice.slice(0, sentenceBreak + 1).trim();
|
||
}
|
||
// Avoid cutting an English word in half when spaces are present.
|
||
const lastSpace = slice.lastIndexOf(' ');
|
||
if (lastSpace >= Math.floor(maxChars * 0.6)) {
|
||
return slice.slice(0, lastSpace).trim();
|
||
}
|
||
return slice.replace(/[,,、;;::\-]+$/, '').trim() || slice.trim();
|
||
}
|