mulmocast 2.1.4 → 2.1.6

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.
@@ -1,6 +1,6 @@
1
1
  import { GraphAILogger } from "graphai";
2
2
  import { provider2TTSAgent } from "../utils/provider2agent.js";
3
- import { apiKeyMissingError, agentIncorrectAPIKeyError, agentGenerationError, audioAction, audioFileTarget } from "../utils/error_cause.js";
3
+ import { apiKeyMissingError, agentVoiceLimitReachedError, agentIncorrectAPIKeyError, agentGenerationError, audioAction, audioFileTarget, } from "../utils/error_cause.js";
4
4
  export const ttsElevenlabsAgent = async ({ namedInputs, params, config, }) => {
5
5
  const { text } = namedInputs;
6
6
  const { voice, model, stability, similarityBoost, suppressError } = params;
@@ -57,6 +57,12 @@ export const ttsElevenlabsAgent = async ({ namedInputs, params, config, }) => {
57
57
  cause: agentIncorrectAPIKeyError("ttsElevenlabsAgent", audioAction, audioFileTarget),
58
58
  });
59
59
  }
60
+ const errorDetail = await response.json();
61
+ if (errorDetail.detail.status === "voice_limit_reached") {
62
+ throw new Error("Failed to generate audio: 400 You have reached your maximum amount of custom voices with ElevenLabs", {
63
+ cause: agentVoiceLimitReachedError("ttsElevenlabsAgent", audioAction, audioFileTarget),
64
+ });
65
+ }
60
66
  throw new Error(`Eleven Labs API error: ${response.status} ${response.statusText}`, {
61
67
  cause: agentGenerationError("ttsElevenlabsAgent", audioAction, audioFileTarget),
62
68
  });
@@ -5,7 +5,7 @@ import { agentIncorrectAPIKeyError, apiKeyMissingError, agentGenerationError, au
5
5
  import { pcmToMp3 } from "../utils/ffmpeg_utils.js";
6
6
  export const ttsGeminiAgent = async ({ namedInputs, params, config, }) => {
7
7
  const { text } = namedInputs;
8
- const { voice, suppressError } = params;
8
+ const { model, voice, suppressError } = params;
9
9
  const apiKey = config?.apiKey;
10
10
  if (!apiKey) {
11
11
  throw new Error("Google GenAI API key is required (GEMINI_API_KEY)", {
@@ -15,7 +15,7 @@ export const ttsGeminiAgent = async ({ namedInputs, params, config, }) => {
15
15
  try {
16
16
  const ai = new GoogleGenAI({ apiKey });
17
17
  const response = await ai.models.generateContent({
18
- model: "gemini-2.5-flash-preview-tts",
18
+ model: model ?? provider2TTSAgent.gemini.defaultModel,
19
19
  contents: [{ parts: [{ text }] }],
20
20
  config: {
21
21
  responseModalities: ["AUDIO"],
@@ -121,6 +121,7 @@ export type KotodamaTTSAgentParams = TTSAgentParams & {
121
121
  };
122
122
  export type GoogleTTSAgentParams = TTSAgentParams & {
123
123
  speed: number;
124
+ model: string;
124
125
  };
125
126
  export type ElevenlabsTTSAgentParams = TTSAgentParams & {
126
127
  model: string;
@@ -54,6 +54,7 @@ export declare const apiKeyInvalidType = "apiKeyInvalid";
54
54
  export declare const apiRateLimitErrorType = "apiRateLimit";
55
55
  export declare const apiKeyMissingType = "apiKeyMissing";
56
56
  export declare const invalidResponseType = "invalidResponse";
57
+ export declare const voiceLimitReachedType = "voice_limit_reached";
57
58
  export declare const movieAction = "movie";
58
59
  export declare const imageAction = "images";
59
60
  export declare const audioAction = "audio";
@@ -174,6 +175,12 @@ export declare const agentIncorrectAPIKeyError: (agentName: string, action: stri
174
175
  target: string;
175
176
  agentName: string;
176
177
  };
178
+ export declare const agentVoiceLimitReachedError: (agentName: string, action: string, target: string) => {
179
+ type: string;
180
+ action: string;
181
+ target: string;
182
+ agentName: string;
183
+ };
177
184
  export declare const agentAPIRateLimitError: (agentName: string, action: string, target: string, beatIndex?: number) => {
178
185
  beatIndex?: number | undefined;
179
186
  type: string;
@@ -55,6 +55,7 @@ export const apiKeyInvalidType = "apiKeyInvalid";
55
55
  export const apiRateLimitErrorType = "apiRateLimit";
56
56
  export const apiKeyMissingType = "apiKeyMissing";
57
57
  export const invalidResponseType = "invalidResponse";
58
+ export const voiceLimitReachedType = "voice_limit_reached";
58
59
  // Actions
59
60
  export const movieAction = "movie";
60
61
  export const imageAction = "images";
@@ -194,6 +195,14 @@ export const agentIncorrectAPIKeyError = (agentName, action, target, beatIndex)
194
195
  ...(beatIndex !== undefined && { beatIndex }),
195
196
  };
196
197
  };
198
+ export const agentVoiceLimitReachedError = (agentName, action, target) => {
199
+ return {
200
+ type: voiceLimitReachedType,
201
+ action,
202
+ target,
203
+ agentName,
204
+ };
205
+ };
197
206
  // Agent API/Rate Limit Errors
198
207
  export const agentAPIRateLimitError = (agentName, action, target, beatIndex) => {
199
208
  return {
@@ -17,6 +17,10 @@ export const nijovoiceTextAgentFilter = async (context, next) => {
17
17
  };
18
18
  export const fileCacheAgentFilter = async (context, next) => {
19
19
  const { force, file, index, mulmoContext, sessionType, id, withBackup } = context.namedInputs.cache;
20
+ const fileName = path.resolve(path.dirname(file), id + ".mp3");
21
+ if (fs.existsSync(file)) {
22
+ fs.copyFileSync(file, fileName);
23
+ }
20
24
  const shouldUseCache = async () => {
21
25
  if (force && force.some((element) => element)) {
22
26
  return false;
@@ -20,7 +20,9 @@ export declare const provider2TTSAgent: {
20
20
  gemini: {
21
21
  agentName: string;
22
22
  hasLimitedConcurrency: boolean;
23
+ defaultModel: string;
23
24
  defaultVoice: string;
25
+ models: string[];
24
26
  keyName: string;
25
27
  };
26
28
  elevenlabs: {
@@ -21,7 +21,9 @@ export const provider2TTSAgent = {
21
21
  gemini: {
22
22
  agentName: "ttsGeminiAgent",
23
23
  hasLimitedConcurrency: false,
24
+ defaultModel: "gemini-2.5-flash-preview-tts",
24
25
  defaultVoice: "Kore",
26
+ models: ["gemini-2.5-flash-preview-tts", "gemini-2.5-pro-preview-tts"],
25
27
  keyName: "GEMINI_API_KEY",
26
28
  },
27
29
  elevenlabs: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mulmocast",
3
- "version": "2.1.4",
3
+ "version": "2.1.6",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "lib/index.node.js",
@@ -12,6 +12,7 @@
12
12
  },
13
13
  "Presenter2": {
14
14
  "provider": "gemini",
15
+ "model": "gemini-2.5-pro-preview-tts",
15
16
  "voiceId": "Puck"
16
17
  }
17
18
  }