AI media harness for planning, generating, and editing locally
TypeScript
Allow custom speech languages
Bittie194627691a6
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rsindex 7ef7707..5521f62 100644--- a/src-tauri/src/lib.rs+++ b/src-tauri/src/lib.rs@@ -890,27 +890,6 @@ fn validate_and_normalize_config(mut config: ProjectConfig) -> Result<ProjectConshot.id, job.id, shot.start_seconds));}- if shot.speech_language.as_deref().is_some_and(|language| {- !matches!(- language,- "Arabic"- | "Chinese"- | "English"- | "French"- | "German"- | "Italian"- | "Japanese"- | "Korean"- | "Portuguese"- | "Russian"- | "Spanish"- )- }) {- return Err(format!(- "Shot '{}' in scene '{}' has an unsupported speech language.",- shot.id, job.id- ));- }shot.settings = normalize_shot_tags(shot.settings.take()).map_err(|reason| format!("Shot '{}' {reason}", shot.id))?;}@@ -4007,7 +3986,7 @@ mod tests {}#[test]- fn shot_speech_and_its_supported_language_survive_the_project_round_trip() {+ fn shot_speech_and_custom_languages_survive_the_project_round_trip() {let mut config = scene_fixture();let shot = &mut config.generation_jobs[0].shots.as_mut().unwrap()[0];shot.speech = Some("行こう! Keep this punctuation.".into());@@ -4022,10 +4001,17 @@ mod tests {);assert_eq!(shot.speech_language.as_deref(), Some("Japanese"));- let mut invalid = scene_fixture();- invalid.generation_jobs[0].shots.as_mut().unwrap()[0].speech_language =+ let mut custom = scene_fixture();+ custom.generation_jobs[0].shots.as_mut().unwrap()[0].speech_language =Some("Klingon".into());- assert!(validate_and_normalize_config(invalid).is_err());+ let normalized = validate_and_normalize_config(custom)+ .expect("custom speech languages are not validator errors");+ assert_eq!(+ normalized.generation_jobs[0].shots.as_ref().unwrap()[0]+ .speech_language+ .as_deref(),+ Some("Klingon")+ );}#[test]diff --git a/src/components/workspace/GeneratorView.test.tsx b/src/components/workspace/GeneratorView.test.tsxindex 8bc947f..119502f 100644--- a/src/components/workspace/GeneratorView.test.tsx+++ b/src/components/workspace/GeneratorView.test.tsx@@ -162,6 +162,17 @@ describe("Generator scene controls", () => {expect(snapshot.prompt).toContain("<d>[Korean] 문을 열어 주세요.</d>");});+ it("keeps an LLM-authored custom speech language in the language list", () => {+ const initial = project();+ initial.generationJobs[0].shots![0].speechLanguage = "Klingon";+ setup(parseProjectConfig(initial));+ fireEvent.click(screen.getByRole("button", { name: "Shot 1 of First scene" }));++ const language = screen.getByRole("combobox", { name: "Speech language for shot 1" });+ expect(language).toHaveValue("Klingon");+ expect(within(language).getByRole("option", { name: "Klingon" })).toBeInTheDocument();+ });+it("reorders shots inside a scene while keeping its cut slots", () => {const state = setup();const shotTransfer = transfer();diff --git a/src/components/workspace/SceneEditor.tsx b/src/components/workspace/SceneEditor.tsxindex 53cdb2c..7eea3b9 100644--- a/src/components/workspace/SceneEditor.tsx+++ b/src/components/workspace/SceneEditor.tsx@@ -120,6 +120,10 @@ export function ShotInspector({ job, shots, shot, index, endsAt, duration, referconst dangling = useMemo(() => danglingReferenceTokens(shots, references), [shots, references]);const settings = shot.settings ?? {};const shotNumber = index + 1;+ const speechLanguage = shot.speechLanguage ?? DEFAULT_SPEECH_LANGUAGE;+ const speechLanguages: readonly string[] = SPEECH_LANGUAGES.some((language) => language === speechLanguage)+ ? SPEECH_LANGUAGES+ : [...SPEECH_LANGUAGES, speechLanguage];/* The line, written the way the user reads and types it. What is STORED is`@[ref:<id>]`, which survives a rename and a reorder; what is SHOWN is@@ -227,12 +231,12 @@ export function ShotInspector({ job, shots, shot, index, endsAt, duration, refer<label className="shot-speech__language"><span>Language</span><select- value={shot.speechLanguage ?? DEFAULT_SPEECH_LANGUAGE}+ value={speechLanguage}disabled={disabled}aria-label={`Speech language for shot ${shotNumber}`}- onChange={(event) => onChange({ speechLanguage: event.target.value as SceneShot["speechLanguage"] })}+ onChange={(event) => onChange({ speechLanguage: event.target.value })}>- {SPEECH_LANGUAGES.map((language) => <option key={language} value={language}>{language}</option>)}+ {speechLanguages.map((language) => <option key={language} value={language}>{language}</option>)}</select></label></div>diff --git a/src/lib/project.ts b/src/lib/project.tsindex d86f3a3..1cb081a 100644--- a/src/lib/project.ts+++ b/src/lib/project.ts@@ -11,9 +11,10 @@ export const DEFAULT_GENERATION_STEPS = 20;export const MAX_GENERATION_STEPS = 2_147_483_647;export const RANDOM_GENERATION_SEED = -1;-/** Languages MiniMax H3 documents as stable for dialogue generation. Keep the- * labels verbatim: they are written into the model's required `[Language]`- * marker rather than translated into the UI locale. */+/** Languages MiniMax H3 documents as stable for dialogue generation. These are+ * suggestions, not a validator whitelist: an LLM or user may name another+ * language. Keep every label verbatim because it is written into the model's+ * required `[Language]` marker rather than translated into the UI locale. */export const SPEECH_LANGUAGES = ["Arabic","Chinese",@@ -27,7 +28,7 @@ export const SPEECH_LANGUAGES = ["Russian","Spanish",] as const;-export const speechLanguageSchema = z.enum(SPEECH_LANGUAGES);+export const speechLanguageSchema = z.string();export type SpeechLanguage = z.infer<typeof speechLanguageSchema>;export const DEFAULT_SPEECH_LANGUAGE: SpeechLanguage = "English";