@nimiplatform/app-tools 0.16.0-rc.15 → 0.16.0-rc.18
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 +5 -42
- package/bin/nimi-app.mjs +25 -6
- package/lib/app-dependency-combinations.mjs +1 -0
- package/lib/app-doctor-update.mjs +8 -6
- package/lib/app-info.mjs +39 -19
- package/lib/app-lifecycle-guidance.mjs +1 -1
- package/lib/app-pack.mjs +4 -1
- package/lib/app-project-lifecycle.mjs +32 -12
- package/lib/app-resources.mjs +36 -0
- package/lib/app-scaffold-profiles.mjs +1 -1
- package/lib/app-scaffold.mjs +11 -13
- package/lib/index.mjs +7 -0
- package/lib/public-storefront.mjs +327 -0
- package/lib/storefront-media.mjs +8 -4
- package/lib/storefront-pack.mjs +152 -0
- package/lib/storefront-release-verification.mjs +31 -0
- package/lib/storefront-source.mjs +161 -0
- package/lib/web-coordination.mjs +4 -1
- package/lib/web-scaffold.mjs +3 -3
- package/package.json +9 -6
- package/scripts/sync-app-source.mjs +5 -12
- package/skills/nimi-app-lifecycle/SKILL.md +1 -0
- package/skills/nimi-app-lifecycle/references/storefront.md +28 -0
- package/templates/app-source/src/ai-studio-core/ai-config.ts +12 -0
- package/templates/app-source/src/ai-studio-core/ai-studio-core.css +138 -117
- package/templates/app-source/src/ai-studio-core/history.ts +10 -8
- package/templates/app-source/src/ai-studio-core/host-context.tsx +1 -0
- package/templates/app-source/src/ai-studio-core/job-recovery-panel.tsx +15 -10
- package/templates/app-source/src/ai-studio-core/job-recovery.ts +505 -115
- package/templates/app-source/src/ai-studio-core/messages/en.json +55 -9
- package/templates/app-source/src/ai-studio-core/messages/zh.json +55 -9
- package/templates/app-source/src/ai-studio-core/non-success-presentation.ts +8 -2
- package/templates/app-source/src/ai-studio-core/parameter-fields.tsx +2 -0
- package/templates/app-source/src/ai-studio-core/parameters.ts +5 -4
- package/templates/app-source/src/ai-studio-core/run-target.ts +12 -1
- package/templates/app-source/src/ai-studio-core/runtime-types.ts +3 -0
- package/templates/app-source/src/ai-studio-core/runtime.ts +50 -12
- package/templates/app-source/src/ai-studio-core/section-ai-testing-composer.tsx +6 -7
- package/templates/app-source/src/ai-studio-core/section-ai-testing-history.tsx +88 -27
- package/templates/app-source/src/ai-studio-core/section-ai-testing-input.ts +33 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-music-result.tsx +2 -2
- package/templates/app-source/src/ai-studio-core/section-ai-testing-output.tsx +10 -3
- package/templates/app-source/src/ai-studio-core/section-ai-testing-result.tsx +6 -4
- package/templates/app-source/src/ai-studio-core/section-ai-testing-run.ts +121 -40
- package/templates/app-source/src/ai-studio-core/section-ai-testing-studio-result.tsx +34 -8
- package/templates/app-source/src/ai-studio-core/section-ai-testing-transcript-result.tsx +16 -2
- package/templates/app-source/src/ai-studio-core/section-ai-testing-transcription-result.tsx +18 -7
- package/templates/app-source/src/ai-studio-core/section-ai-testing-vision-result.tsx +1 -1
- package/templates/app-source/src/ai-studio-core/section-ai-testing.tsx +78 -9
- package/templates/app-source/src/ai-studio-core/text-media-replay.ts +2 -1
- package/templates/app-source/src/ai-studio-core/workspace.tsx +138 -3
- package/templates/app-source/src/product-modules/agent-center/index.tsx +19 -3
- package/templates/app-source/src/product-modules/agent-conversation/index.tsx +19 -3
- package/templates/app-source/src/product-modules/agent-realtime/index.tsx +19 -3
- package/templates/app-source/src/product-modules/kit-recipes/gallery.tsx +12 -7
- package/templates/app-source/src/product-modules/kit-recipes/kit-component-gallery-surface.tsx +48 -20
- package/templates/app-source/src/studio-modules/studio-create/messages/en.json +2 -2
- package/templates/app-source/src/studio-modules/studio-create/messages/zh.json +2 -2
- package/templates/app-source/src/studio-modules/studio-create/registration.ts +1 -1
- package/templates/app-source/src/studio-modules/studio-create/runtime.ts +11 -19
- package/templates/app-source/src/studio-modules/studio-media/audio-separate-parameters.tsx +7 -4
- package/templates/app-source/src/studio-modules/studio-media/audio-separate-runtime.ts +14 -10
- package/templates/app-source/src/studio-modules/studio-media/messages/en.json +3 -1
- package/templates/app-source/src/studio-modules/studio-media/messages/zh.json +3 -1
- package/templates/app-source/src/studio-modules/studio-media/music-parameters.tsx +6 -5
- package/templates/app-source/src/studio-modules/studio-media/music-transcription-parameters.tsx +19 -11
- package/templates/app-source/src/studio-modules/studio-media/music-transcription-runtime.ts +14 -10
- package/templates/app-source/src/studio-modules/studio-media/parameter-panel.tsx +54 -16
- package/templates/app-source/src/studio-modules/studio-media/runtime.ts +22 -9
- package/templates/app-source/src/studio-modules/studio-media/vision-runtime.ts +19 -10
- package/templates/app-source/src/studio-modules/studio-media/voice-convert-parameters.tsx +12 -6
- package/templates/app-source/src/studio-modules/studio-media/voice-convert-runtime.ts +11 -9
- package/templates/app-source/src/studio-modules/studio-voice/messages/en.json +5 -0
- package/templates/app-source/src/studio-modules/studio-voice/messages/zh.json +5 -0
- package/templates/app-source/src/studio-modules/studio-voice/parameter-panel.tsx +18 -7
- package/templates/app-source/src/studio-modules/studio-voice/parameters.ts +28 -4
- package/templates/app-source/src/studio-modules/studio-voice/runtime.ts +12 -8
- package/templates/app-source/src/workbench-core/runtime-gate.tsx +171 -44
- package/templates/app-source/src/workbench-core/workbench-core.css +226 -23
- package/templates/app-source/src/workbench-core/workbench-core.tsx +5 -5
- package/templates/app-source.manifest.json +2 -2
- package/templates/default-starter/NIMI_APP.md +11 -3
- package/templates/default-starter.manifest.json +2 -2
- package/templates/storefront-release.yml +97 -0
package/templates/app-source/src/studio-modules/studio-media/music-transcription-parameters.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from 'react';
|
|
2
|
-
import { Button, SelectField } from '@nimiplatform/kit/ui';
|
|
2
|
+
import { Button, Checkbox, SelectField } from '@nimiplatform/kit/ui';
|
|
3
3
|
import type { NimiMusicTranscriptionInputProfile } from '@nimiplatform/sdk/ai';
|
|
4
4
|
import { useAIStudioHost } from '../../ai-studio-core/host-context.js';
|
|
5
5
|
import { StudioNumberParameter, StudioParameterField, type StudioParameterPanelProps } from '../../ai-studio-core/parameter-fields.js';
|
|
@@ -53,26 +53,34 @@ export function MusicTranscriptionFields(props: StudioParameterPanelProps) {
|
|
|
53
53
|
}
|
|
54
54
|
return <div className="space-y-4">
|
|
55
55
|
{!profile ? <p>{t('Transcription.configureInputs')}</p> : <p>{t('Transcription.inputHint', { seconds: profile.maxDurationSeconds, mib: Math.floor(profile.maxSourceBytes / 1048576) })}</p>}
|
|
56
|
-
<
|
|
56
|
+
<fieldset className="studio-parameters__field">
|
|
57
|
+
<legend className="studio-parameters__label">{t('Transcription.source')}</legend>
|
|
57
58
|
<input ref={fileInput} hidden type="file" accept=".mp3,.wav,.flac" onChange={event => {
|
|
58
59
|
const file = event.currentTarget.files?.[0]; event.currentTarget.value = ''; if (file) void importAudio(file);
|
|
59
60
|
}} />
|
|
60
|
-
<
|
|
61
|
+
<div>
|
|
62
|
+
<Button size="sm" tone="secondary" disabled={disabled || !profile} onClick={() => fileInput.current?.click()}>{t(busy ? 'Music.importing' : 'Transcription.chooseSource')}</Button>
|
|
63
|
+
</div>
|
|
61
64
|
{parameters.sourceRelativePath ? <p>{parameters.sourceName}</p> : null}
|
|
62
|
-
</
|
|
65
|
+
</fieldset>
|
|
63
66
|
{profile ? <>
|
|
64
67
|
<StudioParameterField label={t('Transcription.part')}>
|
|
65
68
|
<SelectField value={parameters.requestedPart ?? profile.parts[0]} disabled={disabled}
|
|
66
69
|
options={[...new Set(profiles.flatMap(item => item.parts))].map(value => ({ value, label: t(`Transcription.parts.${value}`) }))}
|
|
67
70
|
onChange={event => { const part = event.currentTarget.value as NonNullable<StudioMusicTranscriptionParameters['requestedPart']>; const next = profiles.find(item => item.parts.includes(part)); update({ ...parameters, requestedPart: part, requestedFormats: next ? [...next.formats] : [] }); }} />
|
|
68
71
|
</StudioParameterField>
|
|
69
|
-
<
|
|
70
|
-
<
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
<fieldset className="studio-parameters__field">
|
|
73
|
+
<legend className="studio-parameters__label">{t('Transcription.formats')}</legend>
|
|
74
|
+
<div className="flex flex-wrap gap-4">{profile.formats.map(format => (
|
|
75
|
+
<Checkbox
|
|
76
|
+
key={format}
|
|
77
|
+
checked={parameters.requestedFormats?.includes(format) ?? false}
|
|
78
|
+
disabled={disabled}
|
|
79
|
+
label={format === 'timeline' ? t('Transcription.timeline') : format.toUpperCase()}
|
|
80
|
+
onChange={event => update({ ...parameters, requestedFormats: event.currentTarget.checked ? [...(parameters.requestedFormats ?? []), format] : parameters.requestedFormats?.filter(item => item !== format) })}
|
|
81
|
+
/>
|
|
82
|
+
))}</div>
|
|
83
|
+
</fieldset>
|
|
76
84
|
{profile.supportsRange ? <>
|
|
77
85
|
<StudioNumberParameter current={parameters} field="startSeconds" label={t('Transcription.start')} onChange={update} disabled={disabled} />
|
|
78
86
|
<StudioNumberParameter current={parameters} field="endSeconds" label={t('Transcription.end')} onChange={update} disabled={disabled} />
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { beginStudioJobRecovery,
|
|
1
|
+
import { beginStudioJobRecovery, StudioRecoveryWriteUnconfirmed, cleanupRejectedStudioRecoveryEntry, createRecordedStudioScenarioJobSession, isDefiniteUninvokedRunnerRejection, recoverStudioJobId, readStudioJobRecovery, restoreSavedStudioJobResult, saveStudioJobRecoveryResult, studioJobRecoverySignal } from '../../ai-studio-core/job-recovery.js';
|
|
2
2
|
import { createStudioScenarioJobClient, projectStudioArtifactRunnerResult, type StudioCapabilityRuntimeContext } from '../../ai-studio-core/runtime.js';
|
|
3
3
|
import type { StudioManagedArtifact } from '../../ai-studio-core/runtime-types.js';
|
|
4
4
|
import type { StudioMusicTranscriptionParameters } from './parameters.js';
|
|
@@ -8,7 +8,7 @@ export async function runMusicTranscribe(context: StudioCapabilityRuntimeContext
|
|
|
8
8
|
const parameters = context.input.parameters as StudioMusicTranscriptionParameters | undefined;
|
|
9
9
|
const client = context.host.client; const signal = context.input.signal;
|
|
10
10
|
if (parameters?.recoverySubmissionId) {
|
|
11
|
-
const entry = (await readStudioJobRecovery(client.storage, 'music.transcribe')).find(item => item.clientSubmissionId === parameters.recoverySubmissionId);
|
|
11
|
+
const entry = (await readStudioJobRecovery(client.storage.assets, 'music.transcribe')).find(item => item.clientSubmissionId === parameters.recoverySubmissionId);
|
|
12
12
|
if (!entry?.sourceAudio) throw new Error(context.host.translate('Music.recoveryMissing'));
|
|
13
13
|
const saved = await restoreSavedStudioJobResult(entry, context.capability.label, 'music.transcribe', client.storage.assets, studioJobRecoverySignal(context.input));
|
|
14
14
|
if (saved) return saved;
|
|
@@ -16,8 +16,7 @@ export async function runMusicTranscribe(context: StudioCapabilityRuntimeContext
|
|
|
16
16
|
const result = await context.host.runners.musicTranscriptionObserve({ runtime: { ai: createStudioScenarioJobClient(context) },
|
|
17
17
|
jobId: recoveredJobId, signal: context.input.observationSignal, cancelSignal: signal, onObservation: context.input.onObservation, abortReason: context.host.abortReason, onJobUpdate: context.input.onJobUpdate });
|
|
18
18
|
const projected = await projectStudioArtifactRunnerResult({ ...context, musicSourceAudio: entry.sourceAudio }, result);
|
|
19
|
-
|
|
20
|
-
return projected;
|
|
19
|
+
return saveStudioJobRecoveryResult(client.storage.assets, entry.clientSubmissionId, projected, 'music.transcribe');
|
|
21
20
|
}
|
|
22
21
|
const invalid = () => context.host.nonSuccess(context.capability, 'input-invalid', context.host.translate('Transcription.configureInputs'));
|
|
23
22
|
if (!parameters?.sourceRelativePath || !parameters.sourceMimeType || !parameters.requestedFormats?.length || !parameters.requestedPart) return invalid();
|
|
@@ -50,15 +49,20 @@ export async function runMusicTranscribe(context: StudioCapabilityRuntimeContext
|
|
|
50
49
|
try {
|
|
51
50
|
signal?.throwIfAborted();
|
|
52
51
|
if (adopted.sizeBytes !== prepared.sizeBytes || adopted.mediaType !== prepared.mimeType) throw new Error('Canonical source adoption changed metadata');
|
|
53
|
-
clientSubmissionId = await beginStudioJobRecovery(client.storage, 'music.transcribe', sourceAudio, undefined,
|
|
52
|
+
clientSubmissionId = await beginStudioJobRecovery(client.storage.assets, 'music.transcribe', sourceAudio, undefined,
|
|
54
53
|
undefined, context.input.recordedRunConfig, context.input.prompt);
|
|
55
|
-
} catch (cause) {
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
} catch (cause) {
|
|
55
|
+
if (!(cause instanceof StudioRecoveryWriteUnconfirmed)) await client.storage.assets.remove(adopted.relativePath);
|
|
56
|
+
throw cause;
|
|
57
|
+
}
|
|
58
|
+
const session = createRecordedStudioScenarioJobSession(context, clientSubmissionId, 'music.transcribe');
|
|
59
|
+
const result = await context.host.runners.musicTranscribe({ runtime: { ai: session.client }, appId: context.host.appId,
|
|
58
60
|
sourceAudio: { artifactId: prepared.artifactId, ...(hasRange ? { range: { startFrame, endFrame } } : {}) },
|
|
59
61
|
requestedFormats: formats, requestedParts: [part], scenarioId: context.scenarioId, surfaceId: context.host.surfaceId,
|
|
60
62
|
signal, observationSignal: context.input.observationSignal, onObservation: context.input.onObservation, abortReason: context.host.abortReason, onJobUpdate: context.input.onJobUpdate });
|
|
63
|
+
if (result.ok === false && !session.wasSubmitInvoked() && isDefiniteUninvokedRunnerRejection(result.error)) {
|
|
64
|
+
await cleanupRejectedStudioRecoveryEntry(client.storage.assets, 'music.transcribe', clientSubmissionId);
|
|
65
|
+
}
|
|
61
66
|
const projected = await projectStudioArtifactRunnerResult({ ...context, musicSourceAudio: sourceAudio }, result);
|
|
62
|
-
|
|
63
|
-
return projected;
|
|
67
|
+
return saveStudioJobRecoveryResult(client.storage.assets, clientSubmissionId, projected, 'music.transcribe');
|
|
64
68
|
}
|
|
@@ -45,11 +45,12 @@ function ImageLayerField(props: { parameters: StudioImageGenerationParameters; f
|
|
|
45
45
|
} catch (failure) { setError(failure instanceof Error ? failure.message : String(failure)); }
|
|
46
46
|
finally { setBusy(false); finishPreparation?.(); }
|
|
47
47
|
}
|
|
48
|
-
return <
|
|
48
|
+
return <fieldset className="studio-parameters__field">
|
|
49
|
+
<legend className="studio-parameters__label">{props.label}</legend>
|
|
49
50
|
<input ref={input} aria-label={props.label} className="studio-parameters__file-input" type="file" accept="image/png" disabled={props.disabled || busy} onChange={event=>void choose(event)} />
|
|
50
51
|
<div className="studio-parameters__file-row"><Button type="button" tone="ghost" size="sm" disabled={props.disabled || busy} onClick={()=>input.current?.click()}>{host.translate(busy?'Studio.parameters.uploadingImage':'Studio.parameters.chooseImageFile')}</Button>{uploaded && uploaded.artifactId===props.parameters[props.field]?<span>{uploaded.name}</span>:null}{props.parameters[props.field]?<Button type="button" tone="ghost" size="sm" disabled={props.disabled || busy} onClick={()=>{const next={...props.parameters};delete next[props.field];props.onChange(next);setUploaded(null);setError('');}}>{host.translate('Studio.parameters.clearLayer')}</Button>:null}</div>
|
|
51
|
-
{error?<small>{error}</small>:null}<small>{props.hint}</small>
|
|
52
|
-
</
|
|
52
|
+
{error?<small role="alert">{error}</small>:null}<small>{props.hint}</small>
|
|
53
|
+
</fieldset>;
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
// @nimi-authority: rule.nimi.runtime.ai-provider.openai-image26
|
|
@@ -162,7 +163,8 @@ function ImageFields(props: StudioParameterPanelProps) {
|
|
|
162
163
|
field: 'referenceImageArtifactId',
|
|
163
164
|
label: t('Studio.parameters.fields.referenceImageFile'),
|
|
164
165
|
render: (routeDisabled) => (
|
|
165
|
-
<
|
|
166
|
+
<fieldset className="studio-parameters__field">
|
|
167
|
+
<legend className="studio-parameters__label">{t('Studio.parameters.fields.referenceImageFile')}</legend>
|
|
166
168
|
<input ref={inputRef} aria-label={t('Studio.parameters.fields.referenceImageFile')} className="studio-parameters__file-input" type="file" accept={imageMimes.join(',')} disabled={props.disabled || routeDisabled || uploading} onChange={(event) => void selectReferenceImage(event)} />
|
|
167
169
|
<div className="studio-parameters__file-row">
|
|
168
170
|
<Button type="button" tone="ghost" size="sm" disabled={props.disabled || routeDisabled || uploading} leadingIcon={<Upload size={14} aria-hidden="true" />} onClick={() => inputRef.current?.click()}>
|
|
@@ -175,9 +177,9 @@ function ImageFields(props: StudioParameterPanelProps) {
|
|
|
175
177
|
</Button>
|
|
176
178
|
) : null}
|
|
177
179
|
</div>
|
|
178
|
-
{uploadError ? <small>{uploadError}</small> : null}
|
|
180
|
+
{uploadError ? <small role="alert">{uploadError}</small> : null}
|
|
179
181
|
<small>{t(props.source === 'cloud' ? 'Studio.parameters.cloudImageReferenceHint' : 'Studio.parameters.imageReferenceHint')}</small>
|
|
180
|
-
</
|
|
182
|
+
</fieldset>
|
|
181
183
|
),
|
|
182
184
|
},
|
|
183
185
|
textField('mask', t('Studio.parameters.fields.mask'), 'https://…'),
|
|
@@ -189,7 +191,40 @@ function ImageFields(props: StudioParameterPanelProps) {
|
|
|
189
191
|
{ field: 'frameCount', label: t('Studio.parameters.fields.animationFrames'), render: disabled => <StudioNumberParameter current={parameters} field="frameCount" label={t('Studio.parameters.fields.animationFrames')} onChange={update} min={2} step={1} disabled={props.disabled || disabled || parameters.outputFormat !== 'gif'} /> },
|
|
190
192
|
{ field: 'frameDurationMs', label: t('Studio.parameters.fields.frameDurationMs'), render: disabled => <StudioNumberParameter current={parameters} field="frameDurationMs" label={t('Studio.parameters.fields.frameDurationMs')} onChange={update} min={20} max={2000} step={10} disabled={props.disabled || disabled || parameters.outputFormat !== 'gif'} /> },
|
|
191
193
|
];
|
|
192
|
-
|
|
194
|
+
const imageInputPosture = (() => {
|
|
195
|
+
const selection = props.effectiveSelection;
|
|
196
|
+
if (!selection || selection.state !== 'ready' || !selection.resource) return 'unknown' as const;
|
|
197
|
+
if (selection.resource.oneofKind === 'local') {
|
|
198
|
+
const implSupports = selection.resource.local.implementationSupportedFeatures.includes('input.image');
|
|
199
|
+
if (!implSupports) return 'unsupported' as const;
|
|
200
|
+
return selection.resource.local.configuredFeatures.includes('input.image')
|
|
201
|
+
? ('ready' as const)
|
|
202
|
+
: ('slot-missing' as const);
|
|
203
|
+
}
|
|
204
|
+
if (selection.resource.oneofKind === 'cloud') {
|
|
205
|
+
return selection.resource.cloud.target.supportedFeatures.includes('input.image')
|
|
206
|
+
? ('ready' as const)
|
|
207
|
+
: ('unsupported' as const);
|
|
208
|
+
}
|
|
209
|
+
return selection.resource.external.target.supportedFeatures.includes('input.image')
|
|
210
|
+
? ('ready' as const)
|
|
211
|
+
: ('unsupported' as const);
|
|
212
|
+
})();
|
|
213
|
+
const imageInputHintKey = imageInputPosture === 'slot-missing'
|
|
214
|
+
? 'Studio.parameters.imageInputSlotMissingHint'
|
|
215
|
+
: imageInputPosture === 'unsupported'
|
|
216
|
+
? 'Studio.parameters.imageInputUnsupportedHint'
|
|
217
|
+
: '';
|
|
218
|
+
return (
|
|
219
|
+
<div className="studio-parameters__stack">
|
|
220
|
+
{imageInputHintKey ? (
|
|
221
|
+
<p className="studio-parameters__note" role="status" data-testid="studio-image-input-posture">
|
|
222
|
+
{t(imageInputHintKey)}
|
|
223
|
+
</p>
|
|
224
|
+
) : null}
|
|
225
|
+
<StudioRouteAwareParameterFields contract={props.contract} source={props.source} fields={fields} translate={translate} />
|
|
226
|
+
</div>
|
|
227
|
+
);
|
|
193
228
|
}
|
|
194
229
|
|
|
195
230
|
function ControlImageField(props: {
|
|
@@ -225,7 +260,8 @@ function ControlImageField(props: {
|
|
|
225
260
|
finish?.();
|
|
226
261
|
}
|
|
227
262
|
}
|
|
228
|
-
return <
|
|
263
|
+
return <fieldset className="studio-parameters__field">
|
|
264
|
+
<legend className="studio-parameters__label">{host.translate('Studio.parameters.fields.controlImage')}</legend>
|
|
229
265
|
<input ref={input} type="file" aria-label={host.translate('Studio.parameters.fields.controlImage')} accept="image/png,image/jpeg" className="studio-parameters__file-input" disabled={props.disabled || busy} onChange={event => void upload(event)} />
|
|
230
266
|
<div className="studio-parameters__file-row">
|
|
231
267
|
<Button type="button" tone="ghost" size="sm" disabled={props.disabled || busy} onClick={() => input.current?.click()}>{host.translate(busy ? 'Studio.parameters.uploadingImage' : 'Studio.parameters.chooseImageFile')}</Button>
|
|
@@ -241,9 +277,9 @@ function ControlImageField(props: {
|
|
|
241
277
|
}}>{host.translate('Studio.parameters.clearLayer')}</Button>
|
|
242
278
|
</> : null}
|
|
243
279
|
</div>
|
|
244
|
-
{error ? <small>{error}</small> : null}
|
|
280
|
+
{error ? <small role="alert">{error}</small> : null}
|
|
245
281
|
<small>{host.translate('Studio.parameters.controlImageHint')}</small>
|
|
246
|
-
</
|
|
282
|
+
</fieldset>;
|
|
247
283
|
}
|
|
248
284
|
|
|
249
285
|
type VideoArtifactField = 'firstFrameArtifactId' | 'lastFrameArtifactId' | 'referenceArtifactId' | 'referenceAudioArtifactIds' | 'referenceVideoArtifactIds';
|
|
@@ -336,7 +372,8 @@ function VideoParameterPanel(props: StudioParameterPanelProps) {
|
|
|
336
372
|
if (field === 'lastFrameArtifactId') delete next.lastFrameImageUrl;
|
|
337
373
|
update(next);
|
|
338
374
|
}} disabled={props.disabled || routeDisabled || uploading} />
|
|
339
|
-
<
|
|
375
|
+
<fieldset className="studio-parameters__field">
|
|
376
|
+
<legend className="studio-parameters__label">{t('Studio.parameters.fields.referenceImageFile')}</legend>
|
|
340
377
|
<input ref={(element) => { inputs.current[field] = element; }} aria-label={label} className="studio-parameters__file-input" type="file" multiple={field === 'referenceArtifactId'} accept="image/png,image/jpeg,image/webp,image/gif" disabled={props.disabled || routeDisabled || uploading} onChange={(event) => void selectMedia(event, field)} />
|
|
341
378
|
<div className="studio-parameters__file-row">
|
|
342
379
|
<Button type="button" tone="ghost" size="sm" disabled={props.disabled || routeDisabled || uploading} leadingIcon={<Upload size={14} aria-hidden="true" />} onClick={() => inputs.current[field]?.click()}>{uploading ? t('Studio.parameters.uploadingImage') : t('Studio.parameters.chooseImageFile')}</Button>
|
|
@@ -349,15 +386,16 @@ function VideoParameterPanel(props: StudioParameterPanelProps) {
|
|
|
349
386
|
update(next); setUploadedNames((previous) => ({ ...previous, [field]: undefined }));
|
|
350
387
|
}}>{t('Studio.parameters.clearReferenceImage')}</Button> : null}
|
|
351
388
|
</div>
|
|
352
|
-
{uploadError?.field === field ? <small>{uploadError.message}</small> : null}
|
|
353
|
-
</
|
|
389
|
+
{uploadError?.field === field ? <small role="alert">{uploadError.message}</small> : null}
|
|
390
|
+
</fieldset>
|
|
354
391
|
</div>,
|
|
355
392
|
});
|
|
356
393
|
const mediaReferences = (field: 'referenceAudioArtifactIds' | 'referenceVideoArtifactIds'): StudioParameterFieldDefinition => {
|
|
357
394
|
const audio = field === 'referenceAudioArtifactIds';
|
|
358
395
|
const label = t(audio ? 'Studio.parameters.fields.referenceAudioArtifactIds' : 'Studio.parameters.fields.referenceVideoArtifactIds');
|
|
359
396
|
return { field, label,
|
|
360
|
-
render: (routeDisabled) => <
|
|
397
|
+
render: (routeDisabled) => <fieldset className="studio-parameters__field">
|
|
398
|
+
<legend className="studio-parameters__label">{label}</legend>
|
|
361
399
|
<TextareaField aria-label={label} value={(parameters[field] ?? []).join('\n')} rows={2} disabled={props.disabled || routeDisabled || uploading}
|
|
362
400
|
onChange={(event) => update({ ...parameters, [field]: event.currentTarget.value.split('\n').map(value => value.trim()).filter(Boolean) })} />
|
|
363
401
|
<input ref={element => { inputs.current[field] = element; }} aria-label={t(audio ? 'Studio.parameters.audioReferenceFiles' : 'Studio.parameters.videoReferenceFiles')} className="studio-parameters__file-input" type="file" multiple accept={audio ? 'audio/wav,audio/mpeg' : 'video/mp4'}
|
|
@@ -367,9 +405,9 @@ function VideoParameterPanel(props: StudioParameterPanelProps) {
|
|
|
367
405
|
{uploadedNames[field]?.ids.length === parameters[field]?.length && uploadedNames[field]?.ids.every((id,index)=>id === parameters[field]?.[index]) ? <span>{uploadedNames[field]?.names}</span> : null}
|
|
368
406
|
{parameters[field]?.length ? <Button type="button" tone="ghost" size="sm" disabled={props.disabled || routeDisabled || uploading} leadingIcon={<Trash2 size={14} aria-hidden="true" />} onClick={() => { const next={...parameters}; delete next[field]; update(next); setUploadedNames(previous=>({...previous,[field]:undefined})); }}>{t(audio ? 'Studio.parameters.clearAudioReference' : 'Studio.parameters.clearVideoReference')}</Button> : null}
|
|
369
407
|
</div>
|
|
370
|
-
{uploadError?.field === field ? <small>{uploadError.message}</small> : null}
|
|
408
|
+
{uploadError?.field === field ? <small role="alert">{uploadError.message}</small> : null}
|
|
371
409
|
<small>{t(audio ? 'Studio.parameters.audioReferenceOrderHint' : 'Studio.parameters.videoReferenceOrderHint')}</small>
|
|
372
|
-
</
|
|
410
|
+
</fieldset>,
|
|
373
411
|
};
|
|
374
412
|
};
|
|
375
413
|
const firstFrame = parameters.mode === 'i2v-first-frame' || parameters.mode === 'i2v-first-last';
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { observeRuntimeImageGenerate, observeRuntimeVideoGenerate } from '@nimiplatform/kit/features/generation/runtime';
|
|
2
2
|
import { ScenarioType } from '@nimiplatform/sdk/runtime/generated';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
beginStudioJobRecovery,
|
|
5
|
+
cleanupRejectedStudioRecoveryEntry,
|
|
6
|
+
createRecordedStudioScenarioJobSession,
|
|
7
|
+
isDefiniteUninvokedRunnerRejection,
|
|
8
|
+
recoverStudioJobId,
|
|
9
|
+
readStudioJobRecovery,
|
|
10
|
+
restoreSavedStudioJobResult,
|
|
11
|
+
saveStudioJobRecoveryResult,
|
|
12
|
+
studioJobRecoverySignal,
|
|
13
|
+
} from '../../ai-studio-core/job-recovery.js';
|
|
4
14
|
import type { StudioCapabilityRuntimeHandlers } from '../../ai-studio-core/runtime-dispatcher.js';
|
|
5
15
|
import { runVisionLocate } from './vision-runtime.js';
|
|
6
16
|
import { runMusicTranscribe } from './music-transcription-runtime.js';
|
|
@@ -75,6 +85,7 @@ async function runImageGenerate(context: StudioCapabilityRuntimeContext) {
|
|
|
75
85
|
surfaceId: context.host.surfaceId,
|
|
76
86
|
observationSignal: context.input.observationSignal,
|
|
77
87
|
onObservation: context.input.onObservation,
|
|
88
|
+
onJobUpdate: context.input.onJobUpdate,
|
|
78
89
|
...(context.input.signal ? {
|
|
79
90
|
signal: context.input.signal,
|
|
80
91
|
abortReason: context.host.abortReason,
|
|
@@ -86,7 +97,7 @@ async function runImageGenerate(context: StudioCapabilityRuntimeContext) {
|
|
|
86
97
|
async function runMusicGenerate(context: StudioCapabilityRuntimeContext) {
|
|
87
98
|
const parameters = context.input.parameters as StudioMusicGenerationParameters | undefined;
|
|
88
99
|
if (parameters?.recoverySubmissionId) {
|
|
89
|
-
const entry = (await readStudioJobRecovery(context.host.client.storage)).find((item) => item.clientSubmissionId === parameters.recoverySubmissionId);
|
|
100
|
+
const entry = (await readStudioJobRecovery(context.host.client.storage.assets)).find((item) => item.clientSubmissionId === parameters.recoverySubmissionId);
|
|
90
101
|
if (!entry) throw new Error(context.host.translate('Music.recoveryMissing'));
|
|
91
102
|
const saved = await restoreSavedStudioJobResult(entry, context.capability.label, 'music.generate', context.host.client.storage.assets, studioJobRecoverySignal(context.input));
|
|
92
103
|
if (saved) return saved;
|
|
@@ -94,8 +105,7 @@ async function runMusicGenerate(context: StudioCapabilityRuntimeContext) {
|
|
|
94
105
|
const result = await context.host.runners.musicObserve({ runtime: { ai: createStudioScenarioJobClient(context) },
|
|
95
106
|
jobId: recoveredJobId, signal: context.input.observationSignal, cancelSignal: context.input.signal, onObservation: context.input.onObservation, abortReason: context.host.abortReason, onJobUpdate: context.input.onJobUpdate });
|
|
96
107
|
const projected = await projectStudioArtifactRunnerResult(context, result);
|
|
97
|
-
|
|
98
|
-
return projected;
|
|
108
|
+
return saveStudioJobRecoveryResult(context.host.client.storage.assets, entry.clientSubmissionId, projected);
|
|
99
109
|
}
|
|
100
110
|
const lyrics = parameters?.lyrics ?? '';
|
|
101
111
|
if (!context.prompt) return inputRequired(context);
|
|
@@ -122,11 +132,11 @@ async function runMusicGenerate(context: StudioCapabilityRuntimeContext) {
|
|
|
122
132
|
score = { artifactId: uploaded.artifactId, format: 'abc' };
|
|
123
133
|
}
|
|
124
134
|
// Record the author action before Submit, so a lost response remains recoverable.
|
|
125
|
-
const clientSubmissionId = await beginStudioJobRecovery(context.host.client.storage, 'music.generate', undefined, undefined,
|
|
135
|
+
const clientSubmissionId = await beginStudioJobRecovery(context.host.client.storage.assets, 'music.generate', undefined, undefined,
|
|
126
136
|
undefined, context.input.recordedRunConfig, context.input.prompt);
|
|
127
|
-
const
|
|
137
|
+
const session = createRecordedStudioScenarioJobSession(context, clientSubmissionId, 'music.generate');
|
|
128
138
|
const result = await context.host.runners.musicGenerate({
|
|
129
|
-
runtime: { ai:
|
|
139
|
+
runtime: { ai: session.client },
|
|
130
140
|
appId: context.host.appId,
|
|
131
141
|
prompt: context.prompt,
|
|
132
142
|
lyrics,
|
|
@@ -142,9 +152,11 @@ async function runMusicGenerate(context: StudioCapabilityRuntimeContext) {
|
|
|
142
152
|
onObservation: context.input.onObservation,
|
|
143
153
|
...(context.input.signal ? { signal: context.input.signal, observationSignal: context.input.observationSignal, onObservation: context.input.onObservation, abortReason: context.host.abortReason } : {}),
|
|
144
154
|
});
|
|
155
|
+
if (result.ok === false && !session.wasSubmitInvoked() && isDefiniteUninvokedRunnerRejection(result.error)) {
|
|
156
|
+
await cleanupRejectedStudioRecoveryEntry(context.host.client.storage.assets, 'music.generate', clientSubmissionId);
|
|
157
|
+
}
|
|
145
158
|
const projected = await projectStudioArtifactRunnerResult(context, result);
|
|
146
|
-
|
|
147
|
-
return projected;
|
|
159
|
+
return saveStudioJobRecoveryResult(context.host.client.storage.assets, clientSubmissionId, projected);
|
|
148
160
|
}
|
|
149
161
|
|
|
150
162
|
async function runVideoGenerate(context: StudioCapabilityRuntimeContext) {
|
|
@@ -173,6 +185,7 @@ async function runVideoGenerate(context: StudioCapabilityRuntimeContext) {
|
|
|
173
185
|
surfaceId: context.host.surfaceId,
|
|
174
186
|
observationSignal: context.input.observationSignal,
|
|
175
187
|
onObservation: context.input.onObservation,
|
|
188
|
+
onJobUpdate: context.input.onJobUpdate,
|
|
176
189
|
...(context.input.signal ? {
|
|
177
190
|
signal: context.input.signal,
|
|
178
191
|
abortReason: context.host.abortReason,
|
|
@@ -49,17 +49,26 @@ export async function runVisionLocate(context: StudioCapabilityRuntimeContext) {
|
|
|
49
49
|
throw error;
|
|
50
50
|
}
|
|
51
51
|
if (context.input.signal?.aborted) return abortedBeforeSubmit();
|
|
52
|
-
const { asset } = await adoptStudioJobArtifact(context, upload, await managedStudioAssetPath('vision.locate.source',
|
|
52
|
+
const { asset, created } = await adoptStudioJobArtifact(context, upload, await managedStudioAssetPath('vision.locate.source', crypto.randomUUID(), 0));
|
|
53
53
|
const sourceImage: StudioManagedArtifact = { ...asset, displayName: image.name, previewSource: 'managed-asset' };
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
54
|
+
let result;
|
|
55
|
+
try {
|
|
56
|
+
result = await runNimiRuntimeScenarioJob({
|
|
57
|
+
ai: createStudioScenarioJobClient(context, { sourceImage }),
|
|
58
|
+
request: {
|
|
59
|
+
head: { appId: context.host.appId, subjectUserId: '', timeoutMs: 0 }, scenarioType: ScenarioType.VISION_LOCATE, executionMode: ExecutionMode.ASYNC_JOB,
|
|
60
|
+
spec: { spec: { oneofKind: 'visionLocate', visionLocate: { imageArtifactId: upload.artifactId, query: context.prompt, geometry: context.input.parameters?.geometry === 'point' ? VisionLocateGeometry.POINT : VisionLocateGeometry.BOX } } },
|
|
61
|
+
requestId: '', idempotencyKey: '', labels: {}, extensions: [],
|
|
62
|
+
},
|
|
63
|
+
signal: context.input.signal, observationSignal: context.input.observationSignal, onObservation: context.input.onObservation, abortReason: context.host.abortReason, onJobUpdate: context.input.onJobUpdate,
|
|
64
|
+
});
|
|
65
|
+
} catch (error) {
|
|
66
|
+
// Reclaim the freshly adopted source image only if failure/abort occurred before beginStudioJobAction recorded ownership.
|
|
67
|
+
if (created && !context.jobActionId) {
|
|
68
|
+
await context.host.client.storage.assets.remove(asset.relativePath).catch(() => undefined);
|
|
69
|
+
}
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
63
72
|
return projectLocateResult(context, result, sourceImage, image.dataUrl);
|
|
64
73
|
}
|
|
65
74
|
|
|
@@ -76,13 +76,16 @@ export function VoiceConvertFields(props: StudioParameterPanelProps) {
|
|
|
76
76
|
{!profile ? <p>{t('VoiceConvert.configureInputs')}</p> : <p>{t('VoiceConvert.inputHint', {
|
|
77
77
|
sourceSeconds: profile.maxSourceSeconds, sourceMib: Math.floor(profile.maxSourceBytes / 1048576),
|
|
78
78
|
targetSeconds: profile.maxTargetSeconds, targetMib: Math.floor(profile.maxTargetBytes / 1048576) })}</p>}
|
|
79
|
-
<
|
|
79
|
+
<fieldset className="studio-parameters__field">
|
|
80
|
+
<legend className="studio-parameters__label">{t('VoiceConvert.source')}</legend>
|
|
80
81
|
<input ref={sourceInput} hidden type="file" accept=".mp3,.wav,.flac" onChange={event => {
|
|
81
82
|
const file = event.currentTarget.files?.[0]; event.currentTarget.value = ''; if (file) void importAudio(file, 'source');
|
|
82
83
|
}} />
|
|
83
|
-
<
|
|
84
|
+
<div>
|
|
85
|
+
<Button size="sm" tone="secondary" disabled={disabled || !profile} onClick={() => sourceInput.current?.click()}>{t(busy === 'source' ? 'Music.importing' : 'VoiceConvert.chooseSource')}</Button>
|
|
86
|
+
</div>
|
|
84
87
|
{parameters.sourceRelativePath ? <p>{parameters.sourceName}</p> : null}
|
|
85
|
-
</
|
|
88
|
+
</fieldset>
|
|
86
89
|
{profile ? <>
|
|
87
90
|
{profile.supportsRange ? <>
|
|
88
91
|
<StudioNumberParameter current={parameters} field="sourceStartSeconds" label={t('VoiceConvert.sourceStart')} onChange={update} disabled={disabled} />
|
|
@@ -98,13 +101,16 @@ export function VoiceConvertFields(props: StudioParameterPanelProps) {
|
|
|
98
101
|
}} />
|
|
99
102
|
</StudioParameterField>
|
|
100
103
|
{targetKind === 'reference-audio' ? <>
|
|
101
|
-
<
|
|
104
|
+
<fieldset className="studio-parameters__field">
|
|
105
|
+
<legend className="studio-parameters__label">{t('VoiceConvert.target')}</legend>
|
|
102
106
|
<input ref={targetInput} hidden type="file" accept=".mp3,.wav,.flac" onChange={event => {
|
|
103
107
|
const file = event.currentTarget.files?.[0]; event.currentTarget.value = ''; if (file) void importAudio(file, 'target');
|
|
104
108
|
}} />
|
|
105
|
-
<
|
|
109
|
+
<div>
|
|
110
|
+
<Button size="sm" tone="secondary" disabled={disabled || !profile} onClick={() => targetInput.current?.click()}>{t(busy === 'target' ? 'Music.importing' : 'VoiceConvert.chooseTarget')}</Button>
|
|
111
|
+
</div>
|
|
106
112
|
{parameters.targetRelativePath ? <p>{parameters.targetName}</p> : null}
|
|
107
|
-
</
|
|
113
|
+
</fieldset>
|
|
108
114
|
{profile.supportsRange ? <>
|
|
109
115
|
<StudioNumberParameter current={parameters} field="targetStartSeconds" label={t('VoiceConvert.targetStart')} onChange={update} disabled={disabled} />
|
|
110
116
|
<StudioNumberParameter current={parameters} field="targetEndSeconds" label={t('VoiceConvert.targetEnd')} onChange={update} disabled={disabled} />
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { NimiLocalAppAudioInfo, NimiLocalAppVoiceConvertTargetVoice } from '@nimiplatform/sdk/app';
|
|
2
|
-
import { beginStudioJobRecovery,
|
|
2
|
+
import { beginStudioJobRecovery, StudioRecoveryWriteUnconfirmed, cleanupRejectedStudioRecoveryEntry, createRecordedStudioScenarioJobSession, isDefiniteUninvokedRunnerRejection, recoverStudioJobId, readStudioJobRecovery, restoreSavedStudioJobResult, saveStudioJobRecoveryResult, studioJobRecoverySignal } from '../../ai-studio-core/job-recovery.js';
|
|
3
3
|
import { createStudioScenarioJobClient, projectStudioArtifactRunnerResult, type StudioCapabilityRuntimeContext } from '../../ai-studio-core/runtime.js';
|
|
4
4
|
import type { StudioManagedArtifact } from '../../ai-studio-core/runtime-types.js';
|
|
5
5
|
import type { StudioVoiceConvertParameters } from './parameters.js';
|
|
@@ -9,7 +9,7 @@ export async function runVoiceConvert(context: StudioCapabilityRuntimeContext) {
|
|
|
9
9
|
const parameters = context.input.parameters as StudioVoiceConvertParameters | undefined;
|
|
10
10
|
const client = context.host.client; const signal = context.input.signal;
|
|
11
11
|
if (parameters?.recoverySubmissionId) {
|
|
12
|
-
const entry = (await readStudioJobRecovery(client.storage, 'audio.voice.convert')).find(item => item.clientSubmissionId === parameters.recoverySubmissionId);
|
|
12
|
+
const entry = (await readStudioJobRecovery(client.storage.assets, 'audio.voice.convert')).find(item => item.clientSubmissionId === parameters.recoverySubmissionId);
|
|
13
13
|
if (!entry?.sourceAudio) throw new Error(context.host.translate('Music.recoveryMissing'));
|
|
14
14
|
const saved = await restoreSavedStudioJobResult(entry, context.capability.label, 'audio.voice.convert', client.storage.assets, studioJobRecoverySignal(context.input));
|
|
15
15
|
if (saved) return saved;
|
|
@@ -17,8 +17,7 @@ export async function runVoiceConvert(context: StudioCapabilityRuntimeContext) {
|
|
|
17
17
|
const result = await context.host.runners.voiceConversionObserve({ runtime: { ai: createStudioScenarioJobClient(context) },
|
|
18
18
|
jobId: recoveredJobId, signal: context.input.observationSignal, cancelSignal: signal, onObservation: context.input.onObservation, abortReason: context.host.abortReason, onJobUpdate: context.input.onJobUpdate });
|
|
19
19
|
const projected = await projectStudioArtifactRunnerResult({ ...context, voiceSourceVocal: entry.sourceAudio, voiceTargetAudio: entry.targetAudio }, result);
|
|
20
|
-
|
|
21
|
-
return projected;
|
|
20
|
+
return saveStudioJobRecoveryResult(client.storage.assets, entry.clientSubmissionId, projected, 'audio.voice.convert');
|
|
22
21
|
}
|
|
23
22
|
const invalid = () => context.host.nonSuccess(context.capability, 'input-invalid', context.host.translate('VoiceConvert.configureInputs'));
|
|
24
23
|
const targetKind = parameters?.targetKind;
|
|
@@ -93,22 +92,25 @@ export async function runVoiceConvert(context: StudioCapabilityRuntimeContext) {
|
|
|
93
92
|
if (adopted.sizeBytes !== preparedSource.sizeBytes || adopted.mediaType !== preparedSource.mimeType) throw new Error('Canonical source adoption changed metadata');
|
|
94
93
|
if (preparedTarget && adoptedTarget
|
|
95
94
|
&& (adoptedTarget.sizeBytes !== preparedTarget.sizeBytes || adoptedTarget.mediaType !== preparedTarget.mimeType)) throw new Error('Canonical target adoption changed metadata');
|
|
96
|
-
clientSubmissionId = await beginStudioJobRecovery(client.storage, 'audio.voice.convert', sourceVocal, targetAudio,
|
|
95
|
+
clientSubmissionId = await beginStudioJobRecovery(client.storage.assets, 'audio.voice.convert', sourceVocal, targetAudio,
|
|
97
96
|
undefined, context.input.recordedRunConfig, context.input.prompt);
|
|
98
97
|
} catch (cause) {
|
|
98
|
+
if (cause instanceof StudioRecoveryWriteUnconfirmed) throw cause;
|
|
99
99
|
if (adoptedTarget) await client.storage.assets.remove(adoptedTarget.relativePath);
|
|
100
100
|
await client.storage.assets.remove(adopted.relativePath);
|
|
101
101
|
throw cause;
|
|
102
102
|
}
|
|
103
|
-
const
|
|
104
|
-
const result = await context.host.runners.voiceConvert({ runtime: { ai:
|
|
103
|
+
const session = createRecordedStudioScenarioJobSession(context, clientSubmissionId, 'audio.voice.convert');
|
|
104
|
+
const result = await context.host.runners.voiceConvert({ runtime: { ai: session.client }, appId: context.host.appId,
|
|
105
105
|
sourceVocal: { artifactId: preparedSource.artifactId, ...(sourceRange ? { range: sourceRange } : {}) },
|
|
106
106
|
sourceKind: 'singing', targetVoice, ...(semitoneShift ? { semitoneShift } : {}),
|
|
107
107
|
scenarioId: context.scenarioId, surfaceId: context.host.surfaceId,
|
|
108
108
|
signal, observationSignal: context.input.observationSignal, onObservation: context.input.onObservation, abortReason: context.host.abortReason, onJobUpdate: context.input.onJobUpdate });
|
|
109
|
+
if (result.ok === false && !session.wasSubmitInvoked() && isDefiniteUninvokedRunnerRejection(result.error)) {
|
|
110
|
+
await cleanupRejectedStudioRecoveryEntry(client.storage.assets, 'audio.voice.convert', clientSubmissionId);
|
|
111
|
+
}
|
|
109
112
|
const projected = await projectStudioArtifactRunnerResult({ ...context, voiceSourceVocal: sourceVocal, voiceTargetAudio: targetAudio }, result);
|
|
110
|
-
|
|
111
|
-
return projected;
|
|
113
|
+
return saveStudioJobRecoveryResult(client.storage.assets, clientSubmissionId, projected, 'audio.voice.convert');
|
|
112
114
|
}
|
|
113
115
|
|
|
114
116
|
function resolveRange(startSeconds: number | undefined, endSeconds: number | undefined, info: NimiLocalAppAudioInfo) {
|
|
@@ -66,6 +66,11 @@
|
|
|
66
66
|
"removeFile": "Remove",
|
|
67
67
|
"transcriptionAudioFileSize": "Choose a non-empty audio file up to 32 MiB.",
|
|
68
68
|
"transcriptionAudioFileUnreadable": "Could not read the selected audio file. Choose it again or use another file.",
|
|
69
|
+
"voiceReferenceClearText": "This model accepts reference audio alone. Clear the prompt before creating the voice.",
|
|
70
|
+
"voiceReferenceNeedsText": "Enter the transcript of the reference audio in the prompt.",
|
|
71
|
+
"voiceReferenceUri": "Reference audio HTTPS URL",
|
|
72
|
+
"voiceReferenceUriInvalid": "Enter a valid HTTPS URL without embedded credentials.",
|
|
73
|
+
"voiceReferenceUnsupported": "Provide one reference audio source accepted by the selected model.",
|
|
69
74
|
"voiceReferenceFileTooLarge": "Reference audio must be non-empty and not exceed 20 MiB.",
|
|
70
75
|
"voiceReferenceMimeUnsupported": "Choose a file with an audio MIME type.",
|
|
71
76
|
"voiceSourceReferenceAudio": "Reference audio",
|
|
@@ -66,6 +66,11 @@
|
|
|
66
66
|
"removeFile": "移除",
|
|
67
67
|
"transcriptionAudioFileSize": "请选择不超过 32 MiB 的非空音频文件。",
|
|
68
68
|
"transcriptionAudioFileUnreadable": "无法读取所选音频,请重新选择或换一个文件。",
|
|
69
|
+
"voiceReferenceClearText": "这个模型只接受参考音频。请清空提示词后再创建。",
|
|
70
|
+
"voiceReferenceNeedsText": "请在提示词中填写参考音频的逐字稿。",
|
|
71
|
+
"voiceReferenceUri": "参考音频 HTTPS 地址",
|
|
72
|
+
"voiceReferenceUriInvalid": "请输入有效的 HTTPS 地址,地址中不能包含用户名或密码。",
|
|
73
|
+
"voiceReferenceUnsupported": "请使用所选模型支持的方式提供一份参考音频。",
|
|
69
74
|
"voiceReferenceFileTooLarge": "参考音频必须非空且不得超过 20 MiB。",
|
|
70
75
|
"voiceReferenceMimeUnsupported": "请选择具有音频 MIME 类型的文件。",
|
|
71
76
|
"voiceSourceReferenceAudio": "参考音频",
|
|
@@ -17,6 +17,7 @@ import { useAIStudioHost } from '../../ai-studio-core/host-context.js';
|
|
|
17
17
|
import {
|
|
18
18
|
MAX_STUDIO_AUDIO_UPLOAD_BYTES,
|
|
19
19
|
MAX_STUDIO_VOICE_REFERENCE_AUDIO_BYTES,
|
|
20
|
+
voiceReferenceInput,
|
|
20
21
|
type StudioSpeechSynthesizeParameters,
|
|
21
22
|
type StudioSpeechTranscribeParameters,
|
|
22
23
|
type StudioVoiceCreateParameters,
|
|
@@ -86,7 +87,7 @@ function SpeechSynthesizeFields(props: StudioParameterPanelProps) {
|
|
|
86
87
|
options={voices.map((voice) => ({ value: voice.voiceAssetId, label: `${voice.voiceAssetId} · ${voice.creationSource} · ${voice.status}` }))}
|
|
87
88
|
onValueChange={(voiceAssetId) => update({ ...parameters, voiceAssetId })}
|
|
88
89
|
/>
|
|
89
|
-
{voiceError ? <small>{voiceError}</small> : null}
|
|
90
|
+
{voiceError ? <small role="alert">{voiceError}</small> : null}
|
|
90
91
|
</StudioParameterField>
|
|
91
92
|
),
|
|
92
93
|
}] : []),
|
|
@@ -211,6 +212,7 @@ function VoiceCreateFields(props: StudioParameterPanelProps) {
|
|
|
211
212
|
const inputRef = useRef<HTMLInputElement>(null);
|
|
212
213
|
const [fileError, setFileError] = useState('');
|
|
213
214
|
const creationSource = parameters.creationSource ?? 'reference-audio';
|
|
215
|
+
const referenceInput = voiceReferenceInput(props.effectiveSelection);
|
|
214
216
|
async function selectFile(event: ChangeEvent<HTMLInputElement>) {
|
|
215
217
|
const file = event.currentTarget.files?.[0];
|
|
216
218
|
event.currentTarget.value = '';
|
|
@@ -227,6 +229,7 @@ function VoiceCreateFields(props: StudioParameterPanelProps) {
|
|
|
227
229
|
setFileError('');
|
|
228
230
|
update({
|
|
229
231
|
...parameters,
|
|
232
|
+
referenceAudioUri: undefined,
|
|
230
233
|
referenceAudioFile: {
|
|
231
234
|
name: file.name,
|
|
232
235
|
mimeType,
|
|
@@ -251,7 +254,7 @@ function VoiceCreateFields(props: StudioParameterPanelProps) {
|
|
|
251
254
|
value={creationSource}
|
|
252
255
|
disabled={props.disabled || routeDisabled}
|
|
253
256
|
options={[
|
|
254
|
-
{ value: 'reference-audio', label: t('Studio.parameters.voiceSourceReferenceAudio') },
|
|
257
|
+
{ value: 'reference-audio', disabled: !referenceInput, label: t('Studio.parameters.voiceSourceReferenceAudio') },
|
|
255
258
|
{ value: 'text-description', label: t('Studio.parameters.voiceSourceTextDescription') },
|
|
256
259
|
]}
|
|
257
260
|
onValueChange={(value) => update({ ...parameters, creationSource: value as StudioVoiceCreateParameters['creationSource'] })}
|
|
@@ -260,11 +263,12 @@ function VoiceCreateFields(props: StudioParameterPanelProps) {
|
|
|
260
263
|
),
|
|
261
264
|
},
|
|
262
265
|
...(creationSource === 'reference-audio' ? [
|
|
263
|
-
{
|
|
266
|
+
...(referenceInput?.supportsBytes ? [{
|
|
264
267
|
field: 'referenceAudioFile',
|
|
265
268
|
label: t('Studio.parameters.fields.referenceAudioFile'),
|
|
266
269
|
render: (routeDisabled: boolean) => (
|
|
267
|
-
<
|
|
270
|
+
<fieldset className="studio-parameters__field">
|
|
271
|
+
<legend className="studio-parameters__label">{t('Studio.parameters.fields.referenceAudioFile')}</legend>
|
|
268
272
|
<input ref={inputRef} className="studio-parameters__file-input" type="file" accept="audio/*,.wav,.mp3,.m4a,.ogg,.webm,.flac" disabled={props.disabled || routeDisabled} onChange={(event) => void selectFile(event)} />
|
|
269
273
|
<div className="studio-parameters__file-row">
|
|
270
274
|
<Button type="button" tone="ghost" size="sm" disabled={props.disabled || routeDisabled} leadingIcon={<Upload size={14} aria-hidden="true" />} onClick={() => inputRef.current?.click()}>
|
|
@@ -273,10 +277,17 @@ function VoiceCreateFields(props: StudioParameterPanelProps) {
|
|
|
273
277
|
{parameters.referenceAudioFile ? <span>{parameters.referenceAudioFile.name}</span> : null}
|
|
274
278
|
{parameters.referenceAudioFile ? <Button type="button" tone="ghost" size="sm" disabled={props.disabled || routeDisabled} onClick={() => { const next = { ...parameters }; delete next.referenceAudioFile; update(next); }}>{t('Studio.parameters.removeFile')}</Button> : null}
|
|
275
279
|
</div>
|
|
276
|
-
{fileError ? <small>{fileError}</small> : null}
|
|
277
|
-
</
|
|
280
|
+
{fileError ? <small role="alert">{fileError}</small> : null}
|
|
281
|
+
</fieldset>
|
|
278
282
|
),
|
|
279
|
-
},
|
|
283
|
+
}] : []),
|
|
284
|
+
...(referenceInput?.supportsUri ? [{
|
|
285
|
+
field: 'referenceAudioUri',
|
|
286
|
+
label: t('Studio.parameters.voiceReferenceUri'),
|
|
287
|
+
render: (routeDisabled: boolean) => <StudioTextParameter current={parameters} field="referenceAudioUri"
|
|
288
|
+
label={t('Studio.parameters.voiceReferenceUri')} placeholder="https://…" disabled={props.disabled || routeDisabled}
|
|
289
|
+
onChange={next => update({ ...next, referenceAudioFile: undefined })} />,
|
|
290
|
+
}] : []),
|
|
280
291
|
textField('languageHints', t('Studio.parameters.fields.languageHints'), 'zh, en'),
|
|
281
292
|
] : [
|
|
282
293
|
textField('previewText', t('Studio.parameters.fields.previewText')),
|