@nimiplatform/app-tools 0.1.3 → 0.2.0
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/LICENSE +198 -6
- package/README.md +83 -27
- package/bin/nimi-app.mjs +328 -45
- package/lib/app-access-declaration.mjs +49 -0
- package/lib/app-doctor-update.mjs +411 -149
- package/lib/app-pack.mjs +401 -0
- package/lib/app-project-lifecycle.mjs +1141 -0
- package/lib/app-scaffold-capabilities.mjs +769 -0
- package/lib/app-scaffold-default-source.mjs +21 -0
- package/lib/app-scaffold-profiles.mjs +1093 -0
- package/lib/app-scaffold.mjs +1266 -813
- package/lib/index.mjs +194 -42
- package/lib/simulator-conformance-ast.mjs +498 -0
- package/lib/simulator-conformance-css.mjs +116 -0
- package/lib/simulator-conformance-graph.mjs +757 -0
- package/lib/simulator-conformance.d.mts +14 -0
- package/lib/simulator-conformance.mjs +203 -0
- package/lib/simulator-css-profile.d.mts +27 -0
- package/lib/simulator-css-profile.mjs +531 -0
- package/lib/simulator-kit-export-resolution.mjs +70 -0
- package/lib/simulator-manifest.mjs +334 -0
- package/package.json +66 -3
- package/scripts/dev-shell.mjs +465 -0
- package/scripts/sync-app-source.mjs +300 -0
- package/scripts/sync-scaffold-versions.mjs +91 -0
- package/templates/app-source/LICENSE +21 -0
- package/templates/app-source/src/ai-studio-core/ai-config.ts +100 -0
- package/templates/app-source/src/ai-studio-core/ai-studio-core.css +338 -0
- package/templates/app-source/src/ai-studio-core/contexts.tsx +61 -0
- package/templates/app-source/src/ai-studio-core/history-policy.ts +447 -0
- package/templates/app-source/src/ai-studio-core/history.ts +824 -0
- package/templates/app-source/src/ai-studio-core/host-context.tsx +79 -0
- package/templates/app-source/src/ai-studio-core/index.ts +214 -0
- package/templates/app-source/src/ai-studio-core/messages/en.json +310 -0
- package/templates/app-source/src/ai-studio-core/messages/index.ts +47 -0
- package/templates/app-source/src/ai-studio-core/messages/zh.json +310 -0
- package/templates/app-source/src/ai-studio-core/module-registration.ts +109 -0
- package/templates/app-source/src/ai-studio-core/non-success-presentation.ts +65 -0
- package/templates/app-source/src/ai-studio-core/parameter-fields.tsx +247 -0
- package/templates/app-source/src/ai-studio-core/parameters.ts +110 -0
- package/templates/app-source/src/ai-studio-core/prompt-drafts.ts +69 -0
- package/templates/app-source/src/ai-studio-core/run-target.ts +123 -0
- package/templates/app-source/src/ai-studio-core/runtime-dispatcher.ts +35 -0
- package/templates/app-source/src/ai-studio-core/runtime-types.ts +86 -0
- package/templates/app-source/src/ai-studio-core/runtime.ts +306 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-admission.ts +38 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-ai-config.tsx +30 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-artifact-preview.ts +40 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-composer.tsx +257 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-history.tsx +676 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-input.ts +19 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-output.tsx +291 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-result.tsx +413 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-run.ts +174 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-studio-result.tsx +449 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-surface.tsx +45 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing.tsx +494 -0
- package/templates/app-source/src/ai-studio-core/studio-directives.ts +33 -0
- package/templates/app-source/src/ai-studio-core/workspace.tsx +381 -0
- package/templates/app-source/src/product-modules/agent-center/index.tsx +27 -0
- package/templates/app-source/src/product-modules/agent-conversation/index.tsx +19 -0
- package/templates/app-source/src/product-modules/agent-realtime/index.tsx +29 -0
- package/templates/app-source/src/product-modules/kit-recipes/gallery.tsx +142 -0
- package/templates/app-source/src/product-modules/kit-recipes/index.tsx +19 -0
- package/templates/app-source/src/product-modules/kit-recipes/kit-component-gallery-data-recipes.tsx +336 -0
- package/templates/app-source/src/product-modules/kit-recipes/kit-component-gallery-demos.tsx +165 -0
- package/templates/app-source/src/product-modules/kit-recipes/kit-component-gallery-recipes.tsx +682 -0
- package/templates/app-source/src/product-modules/kit-recipes/kit-component-gallery-surface.tsx +341 -0
- package/templates/app-source/src/studio-modules/studio-create/descriptors.ts +26 -0
- package/templates/app-source/src/studio-modules/studio-create/index.ts +14 -0
- package/templates/app-source/src/studio-modules/studio-create/messages/en.json +67 -0
- package/templates/app-source/src/studio-modules/studio-create/messages/index.ts +5 -0
- package/templates/app-source/src/studio-modules/studio-create/messages/zh.json +67 -0
- package/templates/app-source/src/studio-modules/studio-create/parameter-panel.tsx +153 -0
- package/templates/app-source/src/studio-modules/studio-create/parameters.ts +70 -0
- package/templates/app-source/src/studio-modules/studio-create/registration.ts +46 -0
- package/templates/app-source/src/studio-modules/studio-create/runtime.ts +339 -0
- package/templates/app-source/src/studio-modules/studio-media/descriptors.ts +22 -0
- package/templates/app-source/src/studio-modules/studio-media/index.ts +12 -0
- package/templates/app-source/src/studio-modules/studio-media/messages/en.json +82 -0
- package/templates/app-source/src/studio-modules/studio-media/messages/index.ts +5 -0
- package/templates/app-source/src/studio-modules/studio-media/messages/zh.json +82 -0
- package/templates/app-source/src/studio-modules/studio-media/parameter-panel.tsx +283 -0
- package/templates/app-source/src/studio-modules/studio-media/parameters.ts +94 -0
- package/templates/app-source/src/studio-modules/studio-media/registration.ts +44 -0
- package/templates/app-source/src/studio-modules/studio-media/runtime.ts +113 -0
- package/templates/app-source/src/studio-modules/studio-voice/descriptors.ts +28 -0
- package/templates/app-source/src/studio-modules/studio-voice/index.ts +16 -0
- package/templates/app-source/src/studio-modules/studio-voice/messages/en.json +99 -0
- package/templates/app-source/src/studio-modules/studio-voice/messages/index.ts +5 -0
- package/templates/app-source/src/studio-modules/studio-voice/messages/zh.json +99 -0
- package/templates/app-source/src/studio-modules/studio-voice/parameter-panel.tsx +284 -0
- package/templates/app-source/src/studio-modules/studio-voice/parameters.ts +116 -0
- package/templates/app-source/src/studio-modules/studio-voice/registration.ts +59 -0
- package/templates/app-source/src/studio-modules/studio-voice/runtime.ts +347 -0
- package/templates/app-source/src/workbench-core/empty-state.tsx +31 -0
- package/templates/app-source/src/workbench-core/index.ts +17 -0
- package/templates/app-source/src/workbench-core/runtime-gate.tsx +131 -0
- package/templates/app-source/src/workbench-core/workbench-core.css +255 -0
- package/templates/app-source/src/workbench-core/workbench-core.tsx +140 -0
- package/templates/app-source.manifest.json +333 -0
- package/templates/default-starter/AGENTS.md +33 -0
- package/templates/default-starter/LICENSE +21 -0
- package/templates/default-starter/README.md +41 -0
- package/templates/default-starter/SECURITY.md +5 -0
- package/templates/default-starter/index.html +12 -0
- package/templates/default-starter/scripts/validate.mjs +26 -0
- package/templates/default-starter/src/shell/App.tsx +27 -0
- package/templates/default-starter/src/shell/auth/app-identity.ts +3 -0
- package/templates/default-starter/src/shell/auth/local-app-client.ts +18 -0
- package/templates/default-starter/src/shell/auth/runtime-platform.ts +110 -0
- package/templates/default-starter/src/shell/authenticated-shell.tsx +20 -0
- package/templates/default-starter/src/shell/workbench-target-adapter.ts +40 -0
- package/templates/default-starter/src/styles.css +26 -0
- package/templates/default-starter/src-tauri/Cargo.toml +17 -0
- package/templates/default-starter/src-tauri/build.rs +5 -0
- package/templates/default-starter/src-tauri/capabilities/default.json +7 -0
- package/templates/default-starter/src-tauri/tauri.conf.json +26 -0
- package/templates/default-starter/tsconfig.json +18 -0
- package/templates/default-starter.manifest.json +99 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Capabilities": {
|
|
3
|
+
"audioSynthesize": {
|
|
4
|
+
"label": "Speech Synthesis",
|
|
5
|
+
"summary": "Text → audio.synthesize Scenario Job → typed audio artifact result."
|
|
6
|
+
},
|
|
7
|
+
"audioTranscribe": {
|
|
8
|
+
"label": "Speech Transcribe",
|
|
9
|
+
"summary": "Audio URL → audio.transcribe Scenario Job → typed transcript result."
|
|
10
|
+
},
|
|
11
|
+
"voiceCreate": {
|
|
12
|
+
"label": "Voice Create",
|
|
13
|
+
"summary": "Reference audio or text description → voice.create Scenario Job → reusable VoiceAsset."
|
|
14
|
+
},
|
|
15
|
+
"speechBundle": {
|
|
16
|
+
"label": "Voice Catalog",
|
|
17
|
+
"summary": "Inspect owner-scoped voice references through the protected Runtime voice catalog."
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"Studio": {
|
|
21
|
+
"profiles": {
|
|
22
|
+
"audioSynthesize": {
|
|
23
|
+
"inputTitle": "Test speech synthesis",
|
|
24
|
+
"inputPlaceholder": "Enter the text to synthesize into speech…",
|
|
25
|
+
"primaryLabel": "Synthesize speech",
|
|
26
|
+
"primaryRunningLabel": "Synthesizing…",
|
|
27
|
+
"emptyTitle": "Waiting for audio",
|
|
28
|
+
"emptyHint": "The synthesized audio will appear here once the job returns.",
|
|
29
|
+
"footnote": "The runtime returns audio artifacts from the TTS job."
|
|
30
|
+
},
|
|
31
|
+
"audioTranscribe": {
|
|
32
|
+
"inputTitle": "Test speech transcription",
|
|
33
|
+
"inputPlaceholder": "https://… pointing at the audio asset",
|
|
34
|
+
"primaryLabel": "Transcribe audio",
|
|
35
|
+
"primaryRunningLabel": "Transcribing…",
|
|
36
|
+
"emptyTitle": "Waiting for transcript",
|
|
37
|
+
"emptyHint": "The transcript text will appear here once the job returns.",
|
|
38
|
+
"footnote": "Provide an HTTPS URL or a local audio file up to 32 MiB; the runtime returns the transcript."
|
|
39
|
+
},
|
|
40
|
+
"voiceCreate": {
|
|
41
|
+
"inputTitle": "Create a reusable voice",
|
|
42
|
+
"inputPlaceholder": "Describe the voice, or provide the transcript spoken in the reference audio…",
|
|
43
|
+
"primaryLabel": "Create voice",
|
|
44
|
+
"primaryRunningLabel": "Creating…",
|
|
45
|
+
"emptyTitle": "Waiting for voice creation",
|
|
46
|
+
"emptyHint": "The Runtime VoiceAsset will appear here once the job completes.",
|
|
47
|
+
"footnote": "Choose reference audio or text description; Runtime selects the configured voice.create implementation."
|
|
48
|
+
},
|
|
49
|
+
"speechBundle": {
|
|
50
|
+
"inputTitle": "Test voice catalog",
|
|
51
|
+
"inputPlaceholder": "",
|
|
52
|
+
"inputNote": "No input required — this lists the runtime voice catalog.",
|
|
53
|
+
"primaryLabel": "List voices",
|
|
54
|
+
"primaryRunningLabel": "Loading…",
|
|
55
|
+
"emptyTitle": "Waiting for catalog",
|
|
56
|
+
"emptyHint": "Available runtime voices will appear here.",
|
|
57
|
+
"footnote": "Exercises the typed audio.synthesize voice catalog surface."
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"parameters": {
|
|
61
|
+
"voicePreset": "Preset voice",
|
|
62
|
+
"voiceAsset": "Local voice asset",
|
|
63
|
+
"selectVoiceAsset": "Select a local voice asset",
|
|
64
|
+
"noVoiceAssets": "No local voice assets",
|
|
65
|
+
"chooseAudioFile": "Choose audio file",
|
|
66
|
+
"removeFile": "Remove",
|
|
67
|
+
"audioFileTooLarge": "Audio files must not exceed 32 MiB.",
|
|
68
|
+
"voiceReferenceFileTooLarge": "Reference audio must be non-empty and not exceed 20 MiB.",
|
|
69
|
+
"voiceReferenceMimeUnsupported": "Choose a file with an audio MIME type.",
|
|
70
|
+
"voiceSourceReferenceAudio": "Reference audio",
|
|
71
|
+
"voiceSourceTextDescription": "Text description",
|
|
72
|
+
"fields": {
|
|
73
|
+
"voiceSource": "Voice source",
|
|
74
|
+
"voicePreset": "Preset voice ID",
|
|
75
|
+
"voiceAsset": "Local voice asset",
|
|
76
|
+
"language": "Language",
|
|
77
|
+
"audioFormat": "Audio format",
|
|
78
|
+
"sampleRateHz": "Sample rate (Hz)",
|
|
79
|
+
"speed": "Speed",
|
|
80
|
+
"pitch": "Pitch",
|
|
81
|
+
"volume": "Volume",
|
|
82
|
+
"emotion": "Emotion",
|
|
83
|
+
"timingMode": "Timing mode",
|
|
84
|
+
"audioFile": "Local audio file",
|
|
85
|
+
"mimeType": "MIME type",
|
|
86
|
+
"timestamps": "Timestamps",
|
|
87
|
+
"diarization": "Diarization",
|
|
88
|
+
"speakerCount": "Speaker count",
|
|
89
|
+
"transcriptionPrompt": "Transcription prompt",
|
|
90
|
+
"responseFormat": "Response format",
|
|
91
|
+
"creationSource": "Creation source",
|
|
92
|
+
"referenceAudioFile": "Reference audio",
|
|
93
|
+
"languageHints": "Language hints",
|
|
94
|
+
"preferredName": "Preferred name",
|
|
95
|
+
"previewText": "Preview text"
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AIStudioMessageBundles } from '../../../ai-studio-core/messages/index.js';
|
|
2
|
+
import en from './en.json' with { type: 'json' };
|
|
3
|
+
import zh from './zh.json' with { type: 'json' };
|
|
4
|
+
|
|
5
|
+
export const studioVoiceMessageBundles = Object.freeze({ en, zh }) satisfies AIStudioMessageBundles;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Capabilities": {
|
|
3
|
+
"audioSynthesize": {
|
|
4
|
+
"label": "语音合成",
|
|
5
|
+
"summary": "文本 → audio.synthesize 场景任务 → 类型化音频产物结果。"
|
|
6
|
+
},
|
|
7
|
+
"audioTranscribe": {
|
|
8
|
+
"label": "语音转写",
|
|
9
|
+
"summary": "音频 URL → audio.transcribe 场景任务 → 类型化转写结果。"
|
|
10
|
+
},
|
|
11
|
+
"voiceCreate": {
|
|
12
|
+
"label": "创建语音",
|
|
13
|
+
"summary": "参考音频或文本描述 → voice.create 场景任务 → 可复用 VoiceAsset。"
|
|
14
|
+
},
|
|
15
|
+
"speechBundle": {
|
|
16
|
+
"label": "语音目录",
|
|
17
|
+
"summary": "通过受保护的 Runtime 语音目录查看所有者范围内的语音引用。"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"Studio": {
|
|
21
|
+
"profiles": {
|
|
22
|
+
"audioSynthesize": {
|
|
23
|
+
"inputTitle": "测试语音合成",
|
|
24
|
+
"inputPlaceholder": "输入要合成为语音的文本…",
|
|
25
|
+
"primaryLabel": "合成语音",
|
|
26
|
+
"primaryRunningLabel": "合成中…",
|
|
27
|
+
"emptyTitle": "等待音频",
|
|
28
|
+
"emptyHint": "任务返回后,合成的音频会显示在这里。",
|
|
29
|
+
"footnote": "Runtime 从 TTS 任务返回音频产物。"
|
|
30
|
+
},
|
|
31
|
+
"audioTranscribe": {
|
|
32
|
+
"inputTitle": "测试语音转写",
|
|
33
|
+
"inputPlaceholder": "指向音频资源的 https://… 链接",
|
|
34
|
+
"primaryLabel": "转写音频",
|
|
35
|
+
"primaryRunningLabel": "转写中…",
|
|
36
|
+
"emptyTitle": "等待转写",
|
|
37
|
+
"emptyHint": "任务返回后,转写文本会显示在这里。",
|
|
38
|
+
"footnote": "提供 HTTPS URL 或不超过 32 MiB 的本地音频文件;Runtime 返回转写文本。"
|
|
39
|
+
},
|
|
40
|
+
"voiceCreate": {
|
|
41
|
+
"inputTitle": "创建可复用语音",
|
|
42
|
+
"inputPlaceholder": "描述目标语音,或填写参考音频中说出的文本…",
|
|
43
|
+
"primaryLabel": "创建语音",
|
|
44
|
+
"primaryRunningLabel": "创建中…",
|
|
45
|
+
"emptyTitle": "等待创建语音",
|
|
46
|
+
"emptyHint": "任务完成后,Runtime VoiceAsset 会显示在这里。",
|
|
47
|
+
"footnote": "选择参考音频或文本描述;Runtime 使用已配置的 voice.create 实现。"
|
|
48
|
+
},
|
|
49
|
+
"speechBundle": {
|
|
50
|
+
"inputTitle": "测试语音目录",
|
|
51
|
+
"inputPlaceholder": "",
|
|
52
|
+
"inputNote": "无需输入 —— 这里列出 Runtime 语音目录。",
|
|
53
|
+
"primaryLabel": "列出语音",
|
|
54
|
+
"primaryRunningLabel": "加载中…",
|
|
55
|
+
"emptyTitle": "等待目录",
|
|
56
|
+
"emptyHint": "可用的 Runtime 语音会显示在这里。",
|
|
57
|
+
"footnote": "调用类型化的 audio.synthesize 语音目录能力。"
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"parameters": {
|
|
61
|
+
"voicePreset": "预设语音",
|
|
62
|
+
"voiceAsset": "本地语音资产",
|
|
63
|
+
"selectVoiceAsset": "选择本地语音资产",
|
|
64
|
+
"noVoiceAssets": "没有本地语音资产",
|
|
65
|
+
"chooseAudioFile": "选择音频文件",
|
|
66
|
+
"removeFile": "移除",
|
|
67
|
+
"audioFileTooLarge": "音频文件不得超过 32 MiB。",
|
|
68
|
+
"voiceReferenceFileTooLarge": "参考音频必须非空且不得超过 20 MiB。",
|
|
69
|
+
"voiceReferenceMimeUnsupported": "请选择具有音频 MIME 类型的文件。",
|
|
70
|
+
"voiceSourceReferenceAudio": "参考音频",
|
|
71
|
+
"voiceSourceTextDescription": "文本描述",
|
|
72
|
+
"fields": {
|
|
73
|
+
"voiceSource": "语音来源",
|
|
74
|
+
"voicePreset": "预设语音 ID",
|
|
75
|
+
"voiceAsset": "本地语音资产",
|
|
76
|
+
"language": "语言",
|
|
77
|
+
"audioFormat": "音频格式",
|
|
78
|
+
"sampleRateHz": "采样率(Hz)",
|
|
79
|
+
"speed": "语速",
|
|
80
|
+
"pitch": "音高",
|
|
81
|
+
"volume": "音量",
|
|
82
|
+
"emotion": "情绪",
|
|
83
|
+
"timingMode": "时间标记模式",
|
|
84
|
+
"audioFile": "本地音频文件",
|
|
85
|
+
"mimeType": "MIME 类型",
|
|
86
|
+
"timestamps": "时间戳",
|
|
87
|
+
"diarization": "说话人分离",
|
|
88
|
+
"speakerCount": "说话人数",
|
|
89
|
+
"transcriptionPrompt": "转写提示词",
|
|
90
|
+
"responseFormat": "响应格式",
|
|
91
|
+
"creationSource": "创建来源",
|
|
92
|
+
"referenceAudioFile": "参考音频",
|
|
93
|
+
"languageHints": "语言提示",
|
|
94
|
+
"preferredName": "语音名称",
|
|
95
|
+
"previewText": "预览文本"
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { useEffect, useRef, useState, type ChangeEvent } from 'react';
|
|
2
|
+
import { Button, SelectField } from '@nimiplatform/kit/ui';
|
|
3
|
+
import { Upload } from 'lucide-react';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
StudioBooleanParameter,
|
|
7
|
+
StudioNumberParameter,
|
|
8
|
+
StudioParameterField,
|
|
9
|
+
StudioParameterPanelFrame,
|
|
10
|
+
StudioRouteAwareParameterFields,
|
|
11
|
+
StudioTextParameter,
|
|
12
|
+
type StudioParameterFieldDefinition,
|
|
13
|
+
type StudioParameterPanelProps,
|
|
14
|
+
type StudioParameterTranslate,
|
|
15
|
+
} from '../../ai-studio-core/parameter-fields.js';
|
|
16
|
+
import { useAIStudioHost } from '../../ai-studio-core/host-context.js';
|
|
17
|
+
import {
|
|
18
|
+
MAX_STUDIO_AUDIO_UPLOAD_BYTES,
|
|
19
|
+
MAX_STUDIO_VOICE_REFERENCE_AUDIO_BYTES,
|
|
20
|
+
type StudioSpeechSynthesizeParameters,
|
|
21
|
+
type StudioSpeechTranscribeParameters,
|
|
22
|
+
type StudioVoiceCreateParameters,
|
|
23
|
+
} from './parameters.js';
|
|
24
|
+
|
|
25
|
+
function SpeechSynthesizeFields(props: StudioParameterPanelProps) {
|
|
26
|
+
const host = useAIStudioHost();
|
|
27
|
+
const { translate: t } = useAIStudioHost();
|
|
28
|
+
const translate: StudioParameterTranslate = (key, values) => t(key, values);
|
|
29
|
+
const parameters = props.parameters as StudioSpeechSynthesizeParameters;
|
|
30
|
+
const update = props.onChange as (next: StudioSpeechSynthesizeParameters) => void;
|
|
31
|
+
const effectiveVoiceKind = (props.contract.project(
|
|
32
|
+
props.source,
|
|
33
|
+
parameters,
|
|
34
|
+
) as StudioSpeechSynthesizeParameters).voiceKind;
|
|
35
|
+
const [voices, setVoices] = useState<readonly { voiceAssetId: string; creationSource: string; status: string }[]>([]);
|
|
36
|
+
const [voiceError, setVoiceError] = useState('');
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
let cancelled = false;
|
|
39
|
+
void host.sdk.listLocalAppVoiceAssets().then(
|
|
40
|
+
(assets) => { if (!cancelled) setVoices(assets); },
|
|
41
|
+
(error) => { if (!cancelled) setVoiceError(error instanceof Error ? error.message : String(error)); },
|
|
42
|
+
);
|
|
43
|
+
return () => { cancelled = true; };
|
|
44
|
+
}, [host]);
|
|
45
|
+
const textField = (field: keyof StudioSpeechSynthesizeParameters, label: string): StudioParameterFieldDefinition => ({
|
|
46
|
+
field,
|
|
47
|
+
label,
|
|
48
|
+
render: (routeDisabled) => <StudioTextParameter current={parameters} field={field} label={label} onChange={update} disabled={props.disabled || routeDisabled} />,
|
|
49
|
+
});
|
|
50
|
+
const numberField = (field: keyof StudioSpeechSynthesizeParameters, label: string, min?: number): StudioParameterFieldDefinition => ({
|
|
51
|
+
field,
|
|
52
|
+
label,
|
|
53
|
+
render: (routeDisabled) => <StudioNumberParameter current={parameters} field={field} label={label} onChange={update} disabled={props.disabled || routeDisabled} min={min} />,
|
|
54
|
+
});
|
|
55
|
+
const voiceSourceLabel = t('Studio.parameters.fields.voiceSource');
|
|
56
|
+
const timingModeLabel = t('Studio.parameters.fields.timingMode');
|
|
57
|
+
const fields: StudioParameterFieldDefinition[] = [
|
|
58
|
+
{
|
|
59
|
+
field: 'voiceKind',
|
|
60
|
+
label: voiceSourceLabel,
|
|
61
|
+
render: (routeDisabled) => (
|
|
62
|
+
<StudioParameterField label={voiceSourceLabel}>
|
|
63
|
+
<SelectField
|
|
64
|
+
value={parameters.voiceKind}
|
|
65
|
+
placeholder={t('Studio.parameters.runtimeDefault')}
|
|
66
|
+
disabled={props.disabled || routeDisabled}
|
|
67
|
+
options={[
|
|
68
|
+
{ value: 'preset', label: t('Studio.parameters.voicePreset') },
|
|
69
|
+
{ value: 'asset', label: t('Studio.parameters.voiceAsset') },
|
|
70
|
+
]}
|
|
71
|
+
onValueChange={(value) => update({ ...parameters, voiceKind: value as 'preset' | 'asset' })}
|
|
72
|
+
/>
|
|
73
|
+
</StudioParameterField>
|
|
74
|
+
),
|
|
75
|
+
},
|
|
76
|
+
...(effectiveVoiceKind === 'preset' ? [textField('voicePreset', t('Studio.parameters.fields.voicePreset'))] : []),
|
|
77
|
+
...(effectiveVoiceKind === 'asset' ? [{
|
|
78
|
+
field: 'voiceAssetId',
|
|
79
|
+
label: t('Studio.parameters.fields.voiceAsset'),
|
|
80
|
+
render: (routeDisabled: boolean) => (
|
|
81
|
+
<StudioParameterField label={t('Studio.parameters.fields.voiceAsset')}>
|
|
82
|
+
<SelectField
|
|
83
|
+
value={parameters.voiceAssetId}
|
|
84
|
+
placeholder={voices.length ? t('Studio.parameters.selectVoiceAsset') : t('Studio.parameters.noVoiceAssets')}
|
|
85
|
+
disabled={props.disabled || routeDisabled || voices.length === 0}
|
|
86
|
+
options={voices.map((voice) => ({ value: voice.voiceAssetId, label: `${voice.voiceAssetId} · ${voice.creationSource} · ${voice.status}` }))}
|
|
87
|
+
onValueChange={(voiceAssetId) => update({ ...parameters, voiceAssetId })}
|
|
88
|
+
/>
|
|
89
|
+
{voiceError ? <small>{voiceError}</small> : null}
|
|
90
|
+
</StudioParameterField>
|
|
91
|
+
),
|
|
92
|
+
}] : []),
|
|
93
|
+
textField('language', t('Studio.parameters.fields.language')),
|
|
94
|
+
textField('audioFormat', t('Studio.parameters.fields.audioFormat')),
|
|
95
|
+
numberField('sampleRateHz', t('Studio.parameters.fields.sampleRateHz'), 0),
|
|
96
|
+
numberField('speed', t('Studio.parameters.fields.speed')),
|
|
97
|
+
numberField('pitch', t('Studio.parameters.fields.pitch')),
|
|
98
|
+
numberField('volume', t('Studio.parameters.fields.volume')),
|
|
99
|
+
textField('emotion', t('Studio.parameters.fields.emotion')),
|
|
100
|
+
{
|
|
101
|
+
field: 'timingMode',
|
|
102
|
+
label: timingModeLabel,
|
|
103
|
+
render: (routeDisabled) => (
|
|
104
|
+
<StudioParameterField label={timingModeLabel}>
|
|
105
|
+
<SelectField
|
|
106
|
+
value={parameters.timingMode}
|
|
107
|
+
placeholder={t('Studio.parameters.runtimeDefault')}
|
|
108
|
+
disabled={props.disabled || routeDisabled}
|
|
109
|
+
options={['unspecified', 'none', 'word', 'char'].map((value) => ({ value, label: value }))}
|
|
110
|
+
onValueChange={(timingMode) => update({ ...parameters, timingMode: timingMode as StudioSpeechSynthesizeParameters['timingMode'] })}
|
|
111
|
+
/>
|
|
112
|
+
</StudioParameterField>
|
|
113
|
+
),
|
|
114
|
+
},
|
|
115
|
+
];
|
|
116
|
+
return <StudioRouteAwareParameterFields contract={props.contract} source={props.source} fields={fields} translate={translate} />;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function SpeechTranscribeFields(props: StudioParameterPanelProps) {
|
|
120
|
+
const { translate: t } = useAIStudioHost();
|
|
121
|
+
const translate: StudioParameterTranslate = (key, values) => t(key, values);
|
|
122
|
+
const parameters = props.parameters as StudioSpeechTranscribeParameters;
|
|
123
|
+
const update = props.onChange as (next: StudioSpeechTranscribeParameters) => void;
|
|
124
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
|
125
|
+
const [fileError, setFileError] = useState('');
|
|
126
|
+
async function selectFile(event: ChangeEvent<HTMLInputElement>) {
|
|
127
|
+
const file = event.currentTarget.files?.[0];
|
|
128
|
+
event.currentTarget.value = '';
|
|
129
|
+
if (!file) return;
|
|
130
|
+
if (file.size > MAX_STUDIO_AUDIO_UPLOAD_BYTES) {
|
|
131
|
+
setFileError(t('Studio.parameters.audioFileTooLarge'));
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
const mimeType = file.type || 'application/octet-stream';
|
|
135
|
+
const bytes = new Uint8Array(await file.arrayBuffer());
|
|
136
|
+
setFileError('');
|
|
137
|
+
update({ ...parameters, audioFile: { name: file.name, mimeType, sizeBytes: file.size, bytes }, mimeType });
|
|
138
|
+
}
|
|
139
|
+
const textField = (field: keyof StudioSpeechTranscribeParameters, label: string): StudioParameterFieldDefinition => ({
|
|
140
|
+
field,
|
|
141
|
+
label,
|
|
142
|
+
render: (routeDisabled) => <StudioTextParameter current={parameters} field={field} label={label} onChange={update} disabled={props.disabled || routeDisabled} />,
|
|
143
|
+
});
|
|
144
|
+
const booleanField = (field: keyof StudioSpeechTranscribeParameters, label: string): StudioParameterFieldDefinition => ({
|
|
145
|
+
field,
|
|
146
|
+
label,
|
|
147
|
+
render: (routeDisabled) => <StudioBooleanParameter current={parameters} field={field} label={label} onChange={update} disabled={props.disabled || routeDisabled} />,
|
|
148
|
+
});
|
|
149
|
+
const audioFileLabel = t('Studio.parameters.fields.audioFile');
|
|
150
|
+
const fields: StudioParameterFieldDefinition[] = [
|
|
151
|
+
{
|
|
152
|
+
field: 'audioFile',
|
|
153
|
+
label: audioFileLabel,
|
|
154
|
+
render: (routeDisabled) => (
|
|
155
|
+
<StudioParameterField label={audioFileLabel}>
|
|
156
|
+
<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)} />
|
|
157
|
+
<div className="studio-parameters__file-row">
|
|
158
|
+
<Button type="button" tone="ghost" size="sm" disabled={props.disabled || routeDisabled} leadingIcon={<Upload size={14} aria-hidden="true" />} onClick={() => inputRef.current?.click()}>
|
|
159
|
+
{t('Studio.parameters.chooseAudioFile')}
|
|
160
|
+
</Button>
|
|
161
|
+
{parameters.audioFile ? <span>{parameters.audioFile.name}</span> : null}
|
|
162
|
+
{parameters.audioFile ? <Button type="button" tone="ghost" size="sm" disabled={props.disabled || routeDisabled} onClick={() => { const next = { ...parameters }; delete next.audioFile; update(next); }}>{t('Studio.parameters.removeFile')}</Button> : null}
|
|
163
|
+
</div>
|
|
164
|
+
{fileError ? <small>{fileError}</small> : null}
|
|
165
|
+
</StudioParameterField>
|
|
166
|
+
),
|
|
167
|
+
},
|
|
168
|
+
textField('mimeType', t('Studio.parameters.fields.mimeType')),
|
|
169
|
+
textField('language', t('Studio.parameters.fields.language')),
|
|
170
|
+
booleanField('timestamps', t('Studio.parameters.fields.timestamps')),
|
|
171
|
+
booleanField('diarization', t('Studio.parameters.fields.diarization')),
|
|
172
|
+
{
|
|
173
|
+
field: 'speakerCount',
|
|
174
|
+
label: t('Studio.parameters.fields.speakerCount'),
|
|
175
|
+
render: (routeDisabled) => <StudioNumberParameter current={parameters} field="speakerCount" label={t('Studio.parameters.fields.speakerCount')} onChange={update} disabled={props.disabled || routeDisabled} min={0} step={1} />,
|
|
176
|
+
},
|
|
177
|
+
textField('prompt', t('Studio.parameters.fields.transcriptionPrompt')),
|
|
178
|
+
textField('responseFormat', t('Studio.parameters.fields.responseFormat')),
|
|
179
|
+
];
|
|
180
|
+
return <StudioRouteAwareParameterFields contract={props.contract} source={props.source} fields={fields} translate={translate} />;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function VoiceCreateFields(props: StudioParameterPanelProps) {
|
|
184
|
+
const { translate: t } = useAIStudioHost();
|
|
185
|
+
const translate: StudioParameterTranslate = (key, values) => t(key, values);
|
|
186
|
+
const parameters = props.parameters as StudioVoiceCreateParameters;
|
|
187
|
+
const update = props.onChange as (next: StudioVoiceCreateParameters) => void;
|
|
188
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
|
189
|
+
const [fileError, setFileError] = useState('');
|
|
190
|
+
const creationSource = parameters.creationSource ?? 'reference-audio';
|
|
191
|
+
async function selectFile(event: ChangeEvent<HTMLInputElement>) {
|
|
192
|
+
const file = event.currentTarget.files?.[0];
|
|
193
|
+
event.currentTarget.value = '';
|
|
194
|
+
if (!file) return;
|
|
195
|
+
if (file.size === 0 || file.size > MAX_STUDIO_VOICE_REFERENCE_AUDIO_BYTES) {
|
|
196
|
+
setFileError(t('Studio.parameters.voiceReferenceFileTooLarge'));
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
const mimeType = file.type || 'application/octet-stream';
|
|
200
|
+
if (!mimeType.startsWith('audio/')) {
|
|
201
|
+
setFileError(t('Studio.parameters.voiceReferenceMimeUnsupported'));
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
setFileError('');
|
|
205
|
+
update({
|
|
206
|
+
...parameters,
|
|
207
|
+
referenceAudioFile: {
|
|
208
|
+
name: file.name,
|
|
209
|
+
mimeType,
|
|
210
|
+
sizeBytes: file.size,
|
|
211
|
+
bytes: new Uint8Array(await file.arrayBuffer()),
|
|
212
|
+
},
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
const textField = (field: keyof StudioVoiceCreateParameters, label: string, placeholder?: string): StudioParameterFieldDefinition => ({
|
|
216
|
+
field,
|
|
217
|
+
label,
|
|
218
|
+
render: (routeDisabled) => <StudioTextParameter current={parameters} field={field} label={label} placeholder={placeholder} onChange={update} disabled={props.disabled || routeDisabled} />,
|
|
219
|
+
});
|
|
220
|
+
const sourceLabel = t('Studio.parameters.fields.creationSource');
|
|
221
|
+
const fields: StudioParameterFieldDefinition[] = [
|
|
222
|
+
{
|
|
223
|
+
field: 'creationSource',
|
|
224
|
+
label: sourceLabel,
|
|
225
|
+
render: (routeDisabled) => (
|
|
226
|
+
<StudioParameterField label={sourceLabel}>
|
|
227
|
+
<SelectField
|
|
228
|
+
value={creationSource}
|
|
229
|
+
disabled={props.disabled || routeDisabled}
|
|
230
|
+
options={[
|
|
231
|
+
{ value: 'reference-audio', label: t('Studio.parameters.voiceSourceReferenceAudio') },
|
|
232
|
+
{ value: 'text-description', label: t('Studio.parameters.voiceSourceTextDescription') },
|
|
233
|
+
]}
|
|
234
|
+
onValueChange={(value) => update({ ...parameters, creationSource: value as StudioVoiceCreateParameters['creationSource'] })}
|
|
235
|
+
/>
|
|
236
|
+
</StudioParameterField>
|
|
237
|
+
),
|
|
238
|
+
},
|
|
239
|
+
...(creationSource === 'reference-audio' ? [
|
|
240
|
+
{
|
|
241
|
+
field: 'referenceAudioFile',
|
|
242
|
+
label: t('Studio.parameters.fields.referenceAudioFile'),
|
|
243
|
+
render: (routeDisabled: boolean) => (
|
|
244
|
+
<StudioParameterField label={t('Studio.parameters.fields.referenceAudioFile')}>
|
|
245
|
+
<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)} />
|
|
246
|
+
<div className="studio-parameters__file-row">
|
|
247
|
+
<Button type="button" tone="ghost" size="sm" disabled={props.disabled || routeDisabled} leadingIcon={<Upload size={14} aria-hidden="true" />} onClick={() => inputRef.current?.click()}>
|
|
248
|
+
{t('Studio.parameters.chooseAudioFile')}
|
|
249
|
+
</Button>
|
|
250
|
+
{parameters.referenceAudioFile ? <span>{parameters.referenceAudioFile.name}</span> : null}
|
|
251
|
+
{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}
|
|
252
|
+
</div>
|
|
253
|
+
{fileError ? <small>{fileError}</small> : null}
|
|
254
|
+
</StudioParameterField>
|
|
255
|
+
),
|
|
256
|
+
},
|
|
257
|
+
textField('languageHints', t('Studio.parameters.fields.languageHints'), 'zh, en'),
|
|
258
|
+
] : [
|
|
259
|
+
textField('previewText', t('Studio.parameters.fields.previewText')),
|
|
260
|
+
textField('language', t('Studio.parameters.fields.language'), 'zh'),
|
|
261
|
+
]),
|
|
262
|
+
textField('preferredName', t('Studio.parameters.fields.preferredName')),
|
|
263
|
+
];
|
|
264
|
+
return <StudioRouteAwareParameterFields contract={props.contract} source={props.source} fields={fields} translate={translate} />;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export function StudioVoiceParameterPanel(props: StudioParameterPanelProps) {
|
|
268
|
+
const { translate: t } = useAIStudioHost();
|
|
269
|
+
const translate: StudioParameterTranslate = (key, values) => t(key, values);
|
|
270
|
+
let fields = null;
|
|
271
|
+
if (props.capabilityId === 'audio.synthesize') fields = <SpeechSynthesizeFields {...props} />;
|
|
272
|
+
else if (props.capabilityId === 'audio.transcribe') fields = <SpeechTranscribeFields {...props} />;
|
|
273
|
+
else if (props.capabilityId === 'voice.create') fields = <VoiceCreateFields {...props} />;
|
|
274
|
+
if (!fields) return null;
|
|
275
|
+
return (
|
|
276
|
+
<StudioParameterPanelFrame
|
|
277
|
+
translate={translate}
|
|
278
|
+
disabled={props.disabled}
|
|
279
|
+
onReset={() => props.onChange(props.contract.initial())}
|
|
280
|
+
>
|
|
281
|
+
{fields}
|
|
282
|
+
</StudioParameterPanelFrame>
|
|
283
|
+
);
|
|
284
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CLOUD_ONLY_STUDIO_PARAMETER,
|
|
3
|
+
LOCAL_AND_CLOUD_STUDIO_PARAMETER,
|
|
4
|
+
SUPPORTED_STUDIO_PARAMETER,
|
|
5
|
+
defineStudioParameters,
|
|
6
|
+
} from '../../ai-studio-core/parameters.js';
|
|
7
|
+
|
|
8
|
+
export type StudioSpeechSynthesizeParameters = {
|
|
9
|
+
voiceKind?: 'preset' | 'asset';
|
|
10
|
+
voicePreset?: string;
|
|
11
|
+
voiceAssetId?: string;
|
|
12
|
+
language?: string;
|
|
13
|
+
audioFormat?: string;
|
|
14
|
+
sampleRateHz?: number;
|
|
15
|
+
speed?: number;
|
|
16
|
+
pitch?: number;
|
|
17
|
+
volume?: number;
|
|
18
|
+
emotion?: string;
|
|
19
|
+
timingMode?: 'unspecified' | 'none' | 'word' | 'char';
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type StudioAudioFile = {
|
|
23
|
+
name: string;
|
|
24
|
+
mimeType: string;
|
|
25
|
+
sizeBytes: number;
|
|
26
|
+
bytes: Uint8Array;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type StudioSpeechTranscribeParameters = {
|
|
30
|
+
audioFile?: StudioAudioFile;
|
|
31
|
+
mimeType?: string;
|
|
32
|
+
language?: string;
|
|
33
|
+
timestamps?: boolean;
|
|
34
|
+
diarization?: boolean;
|
|
35
|
+
speakerCount?: number;
|
|
36
|
+
prompt?: string;
|
|
37
|
+
responseFormat?: string;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export type StudioVoiceCreateParameters = {
|
|
41
|
+
creationSource?: 'reference-audio' | 'text-description';
|
|
42
|
+
referenceAudioFile?: StudioAudioFile;
|
|
43
|
+
languageHints?: string;
|
|
44
|
+
preferredName?: string;
|
|
45
|
+
previewText?: string;
|
|
46
|
+
language?: string;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const MAX_STUDIO_AUDIO_UPLOAD_BYTES = 32 * 1024 * 1024;
|
|
50
|
+
export const MAX_STUDIO_VOICE_REFERENCE_AUDIO_BYTES = 20 * 1024 * 1024;
|
|
51
|
+
|
|
52
|
+
const LOCAL_PRESET_CLOUD_CONFIGURABLE = Object.freeze({
|
|
53
|
+
local: { kind: 'fixed', value: 'preset' } as const,
|
|
54
|
+
cloud: SUPPORTED_STUDIO_PARAMETER,
|
|
55
|
+
});
|
|
56
|
+
const LOCAL_TEXT_CLOUD_CONFIGURABLE = Object.freeze({
|
|
57
|
+
local: { kind: 'fixed', value: 'text' } as const,
|
|
58
|
+
cloud: SUPPORTED_STUDIO_PARAMETER,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export const studioSpeechSynthesizeParameters = defineStudioParameters<StudioSpeechSynthesizeParameters>({
|
|
62
|
+
initial: () => ({}),
|
|
63
|
+
routeMatrix: {
|
|
64
|
+
voiceKind: LOCAL_PRESET_CLOUD_CONFIGURABLE,
|
|
65
|
+
voicePreset: LOCAL_AND_CLOUD_STUDIO_PARAMETER,
|
|
66
|
+
voiceAssetId: CLOUD_ONLY_STUDIO_PARAMETER,
|
|
67
|
+
language: CLOUD_ONLY_STUDIO_PARAMETER,
|
|
68
|
+
audioFormat: CLOUD_ONLY_STUDIO_PARAMETER,
|
|
69
|
+
sampleRateHz: CLOUD_ONLY_STUDIO_PARAMETER,
|
|
70
|
+
speed: CLOUD_ONLY_STUDIO_PARAMETER,
|
|
71
|
+
pitch: CLOUD_ONLY_STUDIO_PARAMETER,
|
|
72
|
+
volume: CLOUD_ONLY_STUDIO_PARAMETER,
|
|
73
|
+
emotion: CLOUD_ONLY_STUDIO_PARAMETER,
|
|
74
|
+
timingMode: CLOUD_ONLY_STUDIO_PARAMETER,
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
export const studioSpeechTranscribeParameters = defineStudioParameters<StudioSpeechTranscribeParameters>({
|
|
79
|
+
initial: () => ({}),
|
|
80
|
+
routeMatrix: {
|
|
81
|
+
audioFile: LOCAL_AND_CLOUD_STUDIO_PARAMETER,
|
|
82
|
+
mimeType: LOCAL_AND_CLOUD_STUDIO_PARAMETER,
|
|
83
|
+
language: LOCAL_AND_CLOUD_STUDIO_PARAMETER,
|
|
84
|
+
timestamps: CLOUD_ONLY_STUDIO_PARAMETER,
|
|
85
|
+
diarization: CLOUD_ONLY_STUDIO_PARAMETER,
|
|
86
|
+
speakerCount: CLOUD_ONLY_STUDIO_PARAMETER,
|
|
87
|
+
prompt: CLOUD_ONLY_STUDIO_PARAMETER,
|
|
88
|
+
responseFormat: LOCAL_TEXT_CLOUD_CONFIGURABLE,
|
|
89
|
+
},
|
|
90
|
+
summarize: (parameters) => ({
|
|
91
|
+
...parameters,
|
|
92
|
+
...(parameters.audioFile ? {
|
|
93
|
+
audioFile: `${parameters.audioFile.name} (${parameters.audioFile.sizeBytes} bytes)`,
|
|
94
|
+
} : {}),
|
|
95
|
+
}),
|
|
96
|
+
hasAlternativeInput: (parameters) => Boolean(parameters.audioFile),
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
export const studioVoiceCreateParameters = defineStudioParameters<StudioVoiceCreateParameters>({
|
|
100
|
+
initial: () => ({ creationSource: 'text-description' }),
|
|
101
|
+
routeMatrix: {
|
|
102
|
+
creationSource: LOCAL_AND_CLOUD_STUDIO_PARAMETER,
|
|
103
|
+
referenceAudioFile: LOCAL_AND_CLOUD_STUDIO_PARAMETER,
|
|
104
|
+
languageHints: LOCAL_AND_CLOUD_STUDIO_PARAMETER,
|
|
105
|
+
preferredName: LOCAL_AND_CLOUD_STUDIO_PARAMETER,
|
|
106
|
+
previewText: LOCAL_AND_CLOUD_STUDIO_PARAMETER,
|
|
107
|
+
language: LOCAL_AND_CLOUD_STUDIO_PARAMETER,
|
|
108
|
+
},
|
|
109
|
+
summarize: (parameters) => ({
|
|
110
|
+
...parameters,
|
|
111
|
+
...(parameters.referenceAudioFile ? {
|
|
112
|
+
referenceAudioFile: `${parameters.referenceAudioFile.name} (${parameters.referenceAudioFile.sizeBytes} bytes)`,
|
|
113
|
+
} : {}),
|
|
114
|
+
}),
|
|
115
|
+
hasAlternativeInput: (parameters) => Boolean(parameters.referenceAudioFile),
|
|
116
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { AudioWaveform, Captions, ListMusic, Speech } from 'lucide-react';
|
|
2
|
+
import type { AIStudioModuleRegistration } from '../../ai-studio-core/module-registration.js';
|
|
3
|
+
import { studioVoiceDescriptors, type StudioVoiceCapabilityId } from './descriptors.js';
|
|
4
|
+
import {
|
|
5
|
+
studioSpeechSynthesizeParameters,
|
|
6
|
+
studioSpeechTranscribeParameters,
|
|
7
|
+
studioVoiceCreateParameters,
|
|
8
|
+
} from './parameters.js';
|
|
9
|
+
import { EMPTY_STUDIO_PARAMETERS } from '../../ai-studio-core/parameters.js';
|
|
10
|
+
import { StudioVoiceParameterPanel } from './parameter-panel.js';
|
|
11
|
+
|
|
12
|
+
export const studioVoiceModule = Object.freeze({
|
|
13
|
+
id: 'studio-voice', navigationLabel: 'Voice', order: 30,
|
|
14
|
+
capabilities: [
|
|
15
|
+
{
|
|
16
|
+
descriptor: studioVoiceDescriptors[0],
|
|
17
|
+
icon: Speech,
|
|
18
|
+
profile: {
|
|
19
|
+
studioTag: 'Speech', inputTitleKey: 'Studio.profiles.audioSynthesize.inputTitle', inputPlaceholderKey: 'Studio.profiles.audioSynthesize.inputPlaceholder', inputKind: 'prompt', supportsAttachments: false, controls: [], primaryLabelKey: 'Studio.profiles.audioSynthesize.primaryLabel', primaryRunningLabelKey: 'Studio.profiles.audioSynthesize.primaryRunningLabel', resultTitle: 'Synthesized audio', emptyTitleKey: 'Studio.profiles.audioSynthesize.emptyTitle', emptyHintKey: 'Studio.profiles.audioSynthesize.emptyHint', resultKind: 'artifacts', footnoteKey: 'Studio.profiles.audioSynthesize.footnote',
|
|
20
|
+
},
|
|
21
|
+
preset: { id: 'speech-line', label: 'Speech line', prompt: 'Synthesize a short Runtime acceptance sentence.' },
|
|
22
|
+
runtimeMethod: 'runtime.ai.submitScenarioJob:speech_synthesize',
|
|
23
|
+
parameters: studioSpeechSynthesizeParameters,
|
|
24
|
+
parameterPanel: StudioVoiceParameterPanel,
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
descriptor: studioVoiceDescriptors[1],
|
|
28
|
+
icon: Captions,
|
|
29
|
+
profile: {
|
|
30
|
+
studioTag: 'Transcribe', inputTitleKey: 'Studio.profiles.audioTranscribe.inputTitle', inputPlaceholderKey: 'Studio.profiles.audioTranscribe.inputPlaceholder', inputKind: 'url', supportsAttachments: false, controls: [], primaryLabelKey: 'Studio.profiles.audioTranscribe.primaryLabel', primaryRunningLabelKey: 'Studio.profiles.audioTranscribe.primaryRunningLabel', resultTitle: 'Transcript', emptyTitleKey: 'Studio.profiles.audioTranscribe.emptyTitle', emptyHintKey: 'Studio.profiles.audioTranscribe.emptyHint', resultKind: 'transcript', footnoteKey: 'Studio.profiles.audioTranscribe.footnote',
|
|
31
|
+
},
|
|
32
|
+
preset: { id: 'audio-url', label: 'Audio URL', prompt: 'https://example.test/sample.wav' },
|
|
33
|
+
runtimeMethod: 'kit.generation.runRuntimeSpeechTranscribe',
|
|
34
|
+
parameters: studioSpeechTranscribeParameters,
|
|
35
|
+
parameterPanel: StudioVoiceParameterPanel,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
descriptor: studioVoiceDescriptors[2],
|
|
39
|
+
icon: AudioWaveform,
|
|
40
|
+
profile: {
|
|
41
|
+
studioTag: 'Voice', inputTitleKey: 'Studio.profiles.voiceCreate.inputTitle', inputPlaceholderKey: 'Studio.profiles.voiceCreate.inputPlaceholder', inputKind: 'prompt', supportsAttachments: false, controls: [], primaryLabelKey: 'Studio.profiles.voiceCreate.primaryLabel', primaryRunningLabelKey: 'Studio.profiles.voiceCreate.primaryRunningLabel', resultTitle: 'Created voice', emptyTitleKey: 'Studio.profiles.voiceCreate.emptyTitle', emptyHintKey: 'Studio.profiles.voiceCreate.emptyHint', resultKind: 'voice-asset', footnoteKey: 'Studio.profiles.voiceCreate.footnote',
|
|
42
|
+
},
|
|
43
|
+
preset: { id: 'voice-create', label: 'Voice create', prompt: 'Create a warm, clear Mandarin voice for a friendly Nimi assistant.' },
|
|
44
|
+
runtimeMethod: 'sdk.localApp.ai.scenarioJobs.submit:voice-create',
|
|
45
|
+
parameters: studioVoiceCreateParameters,
|
|
46
|
+
parameterPanel: StudioVoiceParameterPanel,
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
descriptor: studioVoiceDescriptors[3],
|
|
50
|
+
icon: ListMusic,
|
|
51
|
+
profile: {
|
|
52
|
+
studioTag: 'Voices', inputTitleKey: 'Studio.profiles.speechBundle.inputTitle', inputPlaceholderKey: 'Studio.profiles.speechBundle.inputPlaceholder', inputKind: 'none', inputNoteKey: 'Studio.profiles.speechBundle.inputNote', supportsAttachments: false, controls: [], primaryLabelKey: 'Studio.profiles.speechBundle.primaryLabel', primaryRunningLabelKey: 'Studio.profiles.speechBundle.primaryRunningLabel', resultTitle: 'Voice catalog', emptyTitleKey: 'Studio.profiles.speechBundle.emptyTitle', emptyHintKey: 'Studio.profiles.speechBundle.emptyHint', resultKind: 'voice-catalog', footnoteKey: 'Studio.profiles.speechBundle.footnote',
|
|
53
|
+
},
|
|
54
|
+
preset: { id: 'voice-catalog', label: 'Voice catalog', prompt: 'List voices through Kit Runtime voice catalog.' },
|
|
55
|
+
runtimeMethod: 'kit.generation.runRuntimeVoiceCatalog',
|
|
56
|
+
parameters: EMPTY_STUDIO_PARAMETERS,
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
} as const satisfies AIStudioModuleRegistration<'studio-voice', StudioVoiceCapabilityId>);
|