mulmocast 2.1.5 → 2.1.7

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.
@@ -30,7 +30,15 @@ const getAudioPathOrUrl = (context, beat, maybeAudioFile) => {
30
30
  export const getBeatAudioPathOrUrl = (text, context, beat, lang) => {
31
31
  const audioDirPath = MulmoStudioContextMethods.getAudioDirPath(context);
32
32
  const { voiceId, provider, speechOptions, model } = MulmoStudioContextMethods.getAudioParam(context, beat, lang);
33
- const hash_string = [text, voiceId, speechOptions?.instruction ?? "", speechOptions?.speed ?? 1.0, provider, model ?? ""].join(":");
33
+ const hash_string = [
34
+ text,
35
+ voiceId,
36
+ speechOptions?.instruction ?? "",
37
+ speechOptions?.speed ?? 1.0,
38
+ provider,
39
+ model ?? "",
40
+ speechOptions?.decoration ?? "",
41
+ ].join(":");
34
42
  GraphAILogger.log(`getBeatAudioPathOrUrl [${hash_string}]`);
35
43
  const audioFileName = `${context.studio.filename}_${text2hash(hash_string)}`;
36
44
  const maybeAudioFile = getAudioFilePath(audioDirPath, context.studio.filename, audioFileName, lang);
@@ -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
  });
@@ -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,12 @@ 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
+ /*
21
+ const fileName = path.resolve(path.dirname(file), id + ".mp3");
22
+ if (fs.existsSync(file)) {
23
+ fs.copyFileSync(file, fileName);
24
+ }
25
+ */
20
26
  const shouldUseCache = async () => {
21
27
  if (force && force.some((element) => element)) {
22
28
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mulmocast",
3
- "version": "2.1.5",
3
+ "version": "2.1.7",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "lib/index.node.js",