mulmocast 2.1.9 → 2.1.10
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.
|
@@ -3,9 +3,16 @@ import { GoogleGenAI } from "@google/genai";
|
|
|
3
3
|
import { provider2TTSAgent } from "../utils/provider2agent.js";
|
|
4
4
|
import { agentIncorrectAPIKeyError, apiKeyMissingError, agentGenerationError, audioAction, audioFileTarget, getGenAIErrorReason, } from "../utils/error_cause.js";
|
|
5
5
|
import { pcmToMp3 } from "../utils/ffmpeg_utils.js";
|
|
6
|
+
const getPrompt = (text, instructions) => {
|
|
7
|
+
// https://ai.google.dev/gemini-api/docs/speech-generation?hl=ja#controllable
|
|
8
|
+
if (instructions) {
|
|
9
|
+
return `### DIRECTOR'S NOTES\n${instructions}\n\n#### TRANSCRIPT\n${text}`;
|
|
10
|
+
}
|
|
11
|
+
return text;
|
|
12
|
+
};
|
|
6
13
|
export const ttsGeminiAgent = async ({ namedInputs, params, config, }) => {
|
|
7
14
|
const { text } = namedInputs;
|
|
8
|
-
const { model, voice, suppressError } = params;
|
|
15
|
+
const { model, voice, suppressError, instructions } = params;
|
|
9
16
|
const apiKey = config?.apiKey;
|
|
10
17
|
if (!apiKey) {
|
|
11
18
|
throw new Error("Google GenAI API key is required (GEMINI_API_KEY)", {
|
|
@@ -16,7 +23,7 @@ export const ttsGeminiAgent = async ({ namedInputs, params, config, }) => {
|
|
|
16
23
|
const ai = new GoogleGenAI({ apiKey });
|
|
17
24
|
const response = await ai.models.generateContent({
|
|
18
25
|
model: model ?? provider2TTSAgent.gemini.defaultModel,
|
|
19
|
-
contents: [{ parts: [{ text }] }],
|
|
26
|
+
contents: [{ parts: [{ text: getPrompt(text, instructions) }] }],
|
|
20
27
|
config: {
|
|
21
28
|
responseModalities: ["AUDIO"],
|
|
22
29
|
speechConfig: {
|
package/lib/types/agent.d.ts
CHANGED
|
@@ -122,6 +122,7 @@ export type KotodamaTTSAgentParams = TTSAgentParams & {
|
|
|
122
122
|
export type GoogleTTSAgentParams = TTSAgentParams & {
|
|
123
123
|
speed: number;
|
|
124
124
|
model: string;
|
|
125
|
+
instructions: string;
|
|
125
126
|
};
|
|
126
127
|
export type ElevenlabsTTSAgentParams = TTSAgentParams & {
|
|
127
128
|
model: string;
|
package/package.json
CHANGED
|
@@ -14,6 +14,14 @@
|
|
|
14
14
|
"provider": "gemini",
|
|
15
15
|
"model": "gemini-2.5-pro-preview-tts",
|
|
16
16
|
"voiceId": "Puck"
|
|
17
|
+
},
|
|
18
|
+
"Presenter2": {
|
|
19
|
+
"provider": "gemini",
|
|
20
|
+
"model": "gemini-2.5-pro-preview-tts",
|
|
21
|
+
"voiceId": "leda",
|
|
22
|
+
"speechOptions": {
|
|
23
|
+
"instruction": "Role: You are a classic Tsundere character. Tone: Sharp, impatient, and defensive, but with underlying hesitation that suggests you actually care deeply. Voice Quality: Higher pitch, energetic, and slightly haughty."
|
|
24
|
+
}
|
|
17
25
|
}
|
|
18
26
|
}
|
|
19
27
|
},
|
|
@@ -52,7 +60,7 @@
|
|
|
52
60
|
}
|
|
53
61
|
},
|
|
54
62
|
{
|
|
55
|
-
"speaker": "
|
|
63
|
+
"speaker": "Presenter2",
|
|
56
64
|
"text": "Hello, I'm a presenter. I have a whisper instruction.",
|
|
57
65
|
"speechOptions": {
|
|
58
66
|
"instruction": "Whisper softly, like a pillow talk."
|