import { useId } from "react"; import { Input, InputNumber, Radio } from "antd"; import { Select } from "@/components/ui/base/select"; import { ImageSettingsTheme } from "@/components/image-settings-panel"; import { audioFormatOptionsForConfig, audioSpeedLabel, audioVoiceOptionsForConfig, isDoubaoAudioConfig, normalizeAudioFormatForConfig, normalizeAudioSpeedValue, normalizeAudioVoiceForConfig } from "@/lib/audio-generation"; import type { CanvasTheme } from "@/lib/canvas-theme"; import type { AiConfig } from "@/stores/use-config-store"; import type { CanvasAudioSettingKey } from "@/components/canvas/canvas-audio-settings-popover"; type AudioSettingsPanelProps = { config: AiConfig; onConfigChange: (key: CanvasAudioSettingKey, value: string) => void; theme: CanvasTheme; showTitle?: boolean; className?: string }; export function AudioSettingsPanel({ config, onConfigChange, theme, showTitle = true, className = "w-[var(--panel-width-compact)] space-y-4" }: AudioSettingsPanelProps) { const listId = useId(); const streaming = isDoubaoAudioConfig(config); const voice = normalizeAudioVoiceForConfig(config, config.audioVoice); const voices = audioVoiceOptionsForConfig(config); const currentVoice = voices.some((item) => item.value === voice) ? voices : [{ value: voice, label: voice || "不指定音色" }, ...voices]; const formats = audioFormatOptionsForConfig(config); const format = normalizeAudioFormatForConfig(config, config.audioFormat); const speed = normalizeAudioSpeedValue(config.audioSpeed); const selectVoice = (value: string) => onConfigChange("audioVoice", value); return (
event.stopPropagation()} onMouseDown={(event) => event.stopPropagation()} aria-label="音频生成参数"> {showTitle ?

音频设置

: null}
音色 {streaming ? ( <>

无参考素材时按提示词生成;可连接最多 3 段音频或 1 张图片,图片与音频不能混用。

selectVoice(event.target.value)} /> {currentVoice.map((item) => ( ))} selectVoice(event.target.value)} options={currentVoice} className="flex flex-wrap gap-2" /> )}
音频格式 onConfigChange("audioFormat", event.target.value)} className="flex flex-wrap gap-2" />
语速 ({ value, label: audioSpeedLabel(value) }))} onChange={(event) => onConfigChange("audioSpeed", event.target.value)} /> { if (value !== null) onConfigChange("audioSpeed", normalizeAudioSpeedValue(String(value))); }} />
{!streaming ? ( ) : null}
); }