Spaces:
No application file
No application file
Create lib/config.ts
Browse files- lib/config.ts +39 -0
lib/config.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export const VALID_MODELS = {
|
| 2 |
+
ACE_STEP: "ACE-Step/ACE-Step-v1-3.5B",
|
| 3 |
+
DREAM_VAE: "daydreamlive/DreamVAE",
|
| 4 |
+
};
|
| 5 |
+
|
| 6 |
+
export function validateModel(model: string) {
|
| 7 |
+
return Object.values(VALID_MODELS).includes(model);
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
export function validateApiKey(key?: string) {
|
| 11 |
+
return typeof key === "string" && key.trim().length > 0;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
// lib/types.ts
|
| 15 |
+
export type VoiceType = "Random" | "Male" | "Female";
|
| 16 |
+
|
| 17 |
+
export interface GenerateRequestBody {
|
| 18 |
+
stylePrompt: string;
|
| 19 |
+
lyricPrompt?: string;
|
| 20 |
+
voice: VoiceType;
|
| 21 |
+
durationSeconds?: number;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
export interface EditRequestBody {
|
| 25 |
+
operation: "cover" | "extend" | "swap_vocal" | "crop";
|
| 26 |
+
trackId: string;
|
| 27 |
+
params?: Record<string, unknown>;
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
// lib/cache.ts
|
| 31 |
+
const genCache = new Map<string, any>();
|
| 32 |
+
|
| 33 |
+
export function getCachedGeneration(key: string) {
|
| 34 |
+
return genCache.get(key);
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
export function setCachedGeneration(key: string, value: any) {
|
| 38 |
+
genCache.set(key, value);
|
| 39 |
+
}
|