@kajidog/mcp-tts-voicevox 0.0.8 → 0.0.9
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.
- package/README.md +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -3
- package/dist/voicevox/index.d.ts +6 -2
- package/dist/voicevox/index.d.ts.map +1 -1
- package/dist/voicevox/index.js +12 -3
- package/dist/voicevox/player.d.ts +4 -0
- package/dist/voicevox/player.d.ts.map +1 -1
- package/dist/voicevox/player.js +8 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -52,6 +52,9 @@ await client.speak("こんにちは");
|
|
|
52
52
|
|
|
53
53
|
// テキストから音声ファイルを生成
|
|
54
54
|
const filePath = await client.generateAudioFile("こんにちは", "./output.wav");
|
|
55
|
+
|
|
56
|
+
// キューをクリア
|
|
57
|
+
await client.clearQueue();
|
|
55
58
|
```
|
|
56
59
|
|
|
57
60
|
## 主な機能
|
|
@@ -59,10 +62,13 @@ const filePath = await client.generateAudioFile("こんにちは", "./output.wav
|
|
|
59
62
|
- **テキスト読み上げ** (`speak`) - テキストを音声に変換して再生
|
|
60
63
|
- **クエリ生成** (`generate_query`) - 音声合成用クエリの作成
|
|
61
64
|
- **ファイル生成** (`synthesize_file`) - クエリから音声ファイルを生成
|
|
65
|
+
- **キュークリア** (`clear_queue`) - 現在の音声合成キューをすべてクリア
|
|
62
66
|
|
|
63
67
|
## 環境変数
|
|
64
68
|
|
|
65
69
|
- `VOICEVOX_URL`: VOICEVOXエンジンのURL(デフォルト: `http://localhost:50021`)
|
|
70
|
+
- `VOICEVOX_DEFAULT_SPEAKER`: デフォルト話者ID(例: `1`)
|
|
71
|
+
- `VOICEVOX_DEFAULT_SPEED_SCALE`: デフォルト再生速度(例: `1.0`)
|
|
66
72
|
|
|
67
73
|
## ライセンス
|
|
68
74
|
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EACL,UAAU,EACV,cAAc,EACd,aAAa,EACb,KAAK,EACL,IAAI,EACJ,eAAe,EAChB,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EACL,UAAU,EACV,cAAc,EACd,aAAa,EACb,KAAK,EACL,IAAI,EACJ,eAAe,EAChB,MAAM,kBAAkB,CAAC;AA4L1B,OAAO,EACL,UAAU,EACV,cAAc,EACd,cAAc,EACd,aAAa,EACb,KAAK,EACL,IAAI,EACJ,eAAe,GAChB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ const types_1 = require("./voicevox/types");
|
|
|
11
11
|
Object.defineProperty(exports, "VoicevoxError", { enumerable: true, get: function () { return types_1.VoicevoxError; } });
|
|
12
12
|
const server = new mcp_js_1.McpServer({
|
|
13
13
|
name: "MCP TTS Voicevox",
|
|
14
|
-
version: "0.0.
|
|
14
|
+
version: "0.0.9",
|
|
15
15
|
description: "A Voicevox server that converts text to speech for playback and saving.",
|
|
16
16
|
});
|
|
17
17
|
// VoicevoxClientを一度だけインスタンス化
|
|
@@ -31,8 +31,8 @@ const handleError = (error) => {
|
|
|
31
31
|
// テキストを音声に変換して再生
|
|
32
32
|
server.tool("speak", "Convert text to speech and play it", {
|
|
33
33
|
text: zod_1.z
|
|
34
|
-
.string()
|
|
35
|
-
.describe("
|
|
34
|
+
.array(zod_1.z.string())
|
|
35
|
+
.describe("Provide an array of sentences to synthesize and play in order. For faster playback start, it is recommended to make the first element short."),
|
|
36
36
|
speaker: zod_1.z
|
|
37
37
|
.number()
|
|
38
38
|
.optional()
|
|
@@ -127,6 +127,18 @@ server.tool("synthesize_file", "Generate an audio file and return its absolute p
|
|
|
127
127
|
return handleError(error);
|
|
128
128
|
}
|
|
129
129
|
});
|
|
130
|
+
// キュークリアツール
|
|
131
|
+
server.tool("clear_queue", "Clear the current synthesis queue", {}, async () => {
|
|
132
|
+
try {
|
|
133
|
+
await voicevoxClient.clearQueue();
|
|
134
|
+
return {
|
|
135
|
+
content: [{ type: "text", text: "キューをクリアしました" }],
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
return handleError(error);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
130
142
|
server.connect(new stdio_js_1.StdioServerTransport()).catch((error) => {
|
|
131
143
|
console.error("Error connecting to MCP transport:", error);
|
|
132
144
|
process.exit(1);
|
package/dist/voicevox/index.d.ts
CHANGED
|
@@ -8,12 +8,12 @@ export declare class VoicevoxClient {
|
|
|
8
8
|
constructor(config: VoicevoxConfig);
|
|
9
9
|
/**
|
|
10
10
|
* テキストを音声に変換して再生します
|
|
11
|
-
* @param text
|
|
11
|
+
* @param text 変換するテキストまたはテキストの配列
|
|
12
12
|
* @param speaker 話者ID(オプション)
|
|
13
13
|
* @param speedScale 再生速度(オプション)
|
|
14
14
|
* @returns 処理結果のメッセージ
|
|
15
15
|
*/
|
|
16
|
-
speak(text: string, speaker?: number, speedScale?: number): Promise<string>;
|
|
16
|
+
speak(text: string | string[], speaker?: number, speedScale?: number): Promise<string>;
|
|
17
17
|
/**
|
|
18
18
|
* テキストから音声合成用クエリを生成します
|
|
19
19
|
* @param text 変換するテキスト
|
|
@@ -58,6 +58,10 @@ export declare class VoicevoxClient {
|
|
|
58
58
|
*/
|
|
59
59
|
private getSpeedScale;
|
|
60
60
|
private validateConfig;
|
|
61
|
+
/**
|
|
62
|
+
* キューをクリア
|
|
63
|
+
*/
|
|
64
|
+
clearQueue(): Promise<void>;
|
|
61
65
|
}
|
|
62
66
|
export * from "./types";
|
|
63
67
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/voicevox/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAKrD,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;IACxC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAc;IAClC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;IACxC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAS;IAC3C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAS;gBAE9B,MAAM,EAAE,cAAc;IASlC;;;;;;OAMG;IACU,KAAK,CAChB,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/voicevox/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAKrD,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;IACxC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAc;IAClC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;IACxC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAS;IAC3C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAS;gBAE9B,MAAM,EAAE,cAAc;IASlC;;;;;;OAMG;IACU,KAAK,CAChB,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,EACvB,OAAO,CAAC,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC;IA+ClB;;;;;;OAMG;IACU,aAAa,CACxB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,UAAU,CAAC;IAYtB;;;;;;;OAOG;IACU,iBAAiB,CAC5B,WAAW,EAAE,MAAM,GAAG,UAAU,EAChC,UAAU,CAAC,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC;IA8ClB;;;;;;OAMG;IACU,sBAAsB,CACjC,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC;IAElB;;;;;;OAMG;IACU,sBAAsB,CACjC,KAAK,EAAE,UAAU,EACjB,OAAO,CAAC,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC;IA4DlB;;;OAGG;IACH,OAAO,CAAC,YAAY;IAIpB;;;OAGG;IACH,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,cAAc;IAWtB;;OAEG;IACU,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CAGzC;AAGD,cAAc,SAAS,CAAC"}
|
package/dist/voicevox/index.js
CHANGED
|
@@ -30,7 +30,7 @@ class VoicevoxClient {
|
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
32
|
* テキストを音声に変換して再生します
|
|
33
|
-
* @param text
|
|
33
|
+
* @param text 変換するテキストまたはテキストの配列
|
|
34
34
|
* @param speaker 話者ID(オプション)
|
|
35
35
|
* @param speedScale 再生速度(オプション)
|
|
36
36
|
* @returns 処理結果のメッセージ
|
|
@@ -39,8 +39,11 @@ class VoicevoxClient {
|
|
|
39
39
|
try {
|
|
40
40
|
const speakerId = this.getSpeakerId(speaker);
|
|
41
41
|
const speed = this.getSpeedScale(speedScale);
|
|
42
|
-
const segments = (0, utils_1.splitText)(text, this.maxSegmentLength);
|
|
43
42
|
const queueManager = this.player.getQueueManager();
|
|
43
|
+
// 文字列配列の場合は直接使用、文字列の場合は分割して配列に変換
|
|
44
|
+
const segments = Array.isArray(text)
|
|
45
|
+
? text
|
|
46
|
+
: (0, utils_1.splitText)(text, this.maxSegmentLength);
|
|
44
47
|
if (segments.length === 0) {
|
|
45
48
|
return "テキストが空です";
|
|
46
49
|
}
|
|
@@ -65,7 +68,7 @@ class VoicevoxClient {
|
|
|
65
68
|
console.error("残りのセグメント処理中にエラーが発生しました:", error);
|
|
66
69
|
});
|
|
67
70
|
}
|
|
68
|
-
return `音声生成キューに追加しました: ${text}`;
|
|
71
|
+
return `音声生成キューに追加しました: ${Array.isArray(text) ? text.join(" ") : text}`;
|
|
69
72
|
}
|
|
70
73
|
catch (error) {
|
|
71
74
|
return (0, error_1.formatError)("音声生成中にエラーが発生しました", error);
|
|
@@ -206,6 +209,12 @@ class VoicevoxClient {
|
|
|
206
209
|
throw new Error("無効なVOICEVOXのURLです");
|
|
207
210
|
}
|
|
208
211
|
}
|
|
212
|
+
/**
|
|
213
|
+
* キューをクリア
|
|
214
|
+
*/
|
|
215
|
+
async clearQueue() {
|
|
216
|
+
return this.player.clearQueue();
|
|
217
|
+
}
|
|
209
218
|
}
|
|
210
219
|
exports.VoicevoxClient = VoicevoxClient;
|
|
211
220
|
// 型定義の再エクスポート
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"player.d.ts","sourceRoot":"","sources":["../../src/voicevox/player.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,oBAAoB,EAAmC,MAAM,SAAS,CAAC;AAiBhF;;;GAGG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,YAAY,CAAuB;IAE3C;;;;OAIG;gBAED,WAAW,GAAE,MAAiC,EAC9C,YAAY,GAAE,MAAU;IAsB1B;;;;OAIG;IACU,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,MAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAMtE;;;;OAIG;IACU,gBAAgB,CAC3B,KAAK,EAAE,UAAU,EACjB,OAAO,GAAE,MAAU,GAClB,OAAO,CAAC,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,CAAC,EAAE,MAAM,EACf,OAAO,GAAE,MAAU,GAClB,OAAO,CAAC,MAAM,CAAC;IAkBlB;;OAEG;IACI,aAAa,IAAI,IAAI;IAI5B;;OAEG;IACI,aAAa,IAAI,IAAI;IAI5B;;OAEG;IACI,cAAc,IAAI,IAAI;IAI7B;;OAEG;IACI,cAAc,IAAI,MAAM;IAI/B;;OAEG;IACI,YAAY,IAAI,OAAO;IAI9B;;OAEG;IACI,SAAS,IAAI,OAAO;IAM3B;;;OAGG;IACI,eAAe,IAAI,oBAAoB;IAI9C;;OAEG;IACU,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CAKzC"}
|
package/dist/voicevox/player.js
CHANGED
|
@@ -140,5 +140,13 @@ class VoicevoxPlayer {
|
|
|
140
140
|
getQueueManager() {
|
|
141
141
|
return this.queueManager;
|
|
142
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* キューをクリア
|
|
145
|
+
*/
|
|
146
|
+
async clearQueue() {
|
|
147
|
+
return withErrorHandling(async () => {
|
|
148
|
+
await this.queueManager.clearQueue();
|
|
149
|
+
}, "キューのクリア中にエラーが発生しました");
|
|
150
|
+
}
|
|
143
151
|
}
|
|
144
152
|
exports.VoicevoxPlayer = VoicevoxPlayer;
|
package/package.json
CHANGED