@kajidog/mcp-tts-voicevox 0.0.8 → 0.0.12

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.
Files changed (66) hide show
  1. package/README.md +86 -9
  2. package/dist/client.d.ts +11 -0
  3. package/dist/client.d.ts.map +1 -0
  4. package/dist/client.js +35 -0
  5. package/dist/client.js.map +1 -0
  6. package/dist/index.browser.d.ts +2 -0
  7. package/dist/index.browser.d.ts.map +1 -0
  8. package/dist/index.browser.js +22 -0
  9. package/dist/index.browser.js.map +1 -0
  10. package/dist/index.d.ts +1 -3
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +98 -121
  13. package/dist/index.js.map +1 -0
  14. package/dist/stdio.d.ts +3 -0
  15. package/dist/stdio.d.ts.map +1 -0
  16. package/dist/stdio.js +197 -0
  17. package/dist/stdio.js.map +1 -0
  18. package/dist/test.js +1 -0
  19. package/dist/test.js.map +1 -0
  20. package/dist/voicevox/api.d.ts +9 -1
  21. package/dist/voicevox/api.d.ts.map +1 -1
  22. package/dist/voicevox/api.js +31 -0
  23. package/dist/voicevox/api.js.map +1 -0
  24. package/dist/voicevox/error.js +1 -0
  25. package/dist/voicevox/error.js.map +1 -0
  26. package/dist/voicevox/index.d.ts +17 -2
  27. package/dist/voicevox/index.d.ts.map +1 -1
  28. package/dist/voicevox/index.js +69 -10
  29. package/dist/voicevox/index.js.map +1 -0
  30. package/dist/voicevox/player.d.ts +4 -0
  31. package/dist/voicevox/player.d.ts.map +1 -1
  32. package/dist/voicevox/player.js +9 -0
  33. package/dist/voicevox/player.js.map +1 -0
  34. package/dist/voicevox/queue/__tests__/manager.test.js +1 -0
  35. package/dist/voicevox/queue/__tests__/manager.test.js.map +1 -0
  36. package/dist/voicevox/queue/audio-generator.d.ts.map +1 -1
  37. package/dist/voicevox/queue/audio-generator.js +14 -2
  38. package/dist/voicevox/queue/audio-generator.js.map +1 -0
  39. package/dist/voicevox/queue/audio-player.d.ts +9 -1
  40. package/dist/voicevox/queue/audio-player.d.ts.map +1 -1
  41. package/dist/voicevox/queue/audio-player.js +176 -4
  42. package/dist/voicevox/queue/audio-player.js.map +1 -0
  43. package/dist/voicevox/queue/event-manager.js +1 -0
  44. package/dist/voicevox/queue/event-manager.js.map +1 -0
  45. package/dist/voicevox/queue/file-manager.d.ts +32 -5
  46. package/dist/voicevox/queue/file-manager.d.ts.map +1 -1
  47. package/dist/voicevox/queue/file-manager.js +255 -13
  48. package/dist/voicevox/queue/file-manager.js.map +1 -0
  49. package/dist/voicevox/queue/index.js +1 -0
  50. package/dist/voicevox/queue/index.js.map +1 -0
  51. package/dist/voicevox/queue/manager.d.ts +5 -0
  52. package/dist/voicevox/queue/manager.d.ts.map +1 -1
  53. package/dist/voicevox/queue/manager.js +23 -0
  54. package/dist/voicevox/queue/manager.js.map +1 -0
  55. package/dist/voicevox/queue/types.js +1 -0
  56. package/dist/voicevox/queue/types.js.map +1 -0
  57. package/dist/voicevox/types.d.ts +16 -0
  58. package/dist/voicevox/types.d.ts.map +1 -1
  59. package/dist/voicevox/types.js +1 -0
  60. package/dist/voicevox/types.js.map +1 -0
  61. package/dist/voicevox/utils.d.ts +19 -0
  62. package/dist/voicevox/utils.d.ts.map +1 -1
  63. package/dist/voicevox/utils.js +98 -1
  64. package/dist/voicevox/utils.js.map +1 -0
  65. package/package.json +40 -5
  66. package/scripts/fix-permissions.js +84 -0
package/README.md CHANGED
@@ -1,16 +1,19 @@
1
1
  # MCP TTS VOICEVOX
2
2
 
3
- VOICEVOXを使用した音声合成MCPサーバー
3
+ VOICEVOX を使用した音声合成 MCP サーバー
4
4
 
5
5
  ## 特徴
6
6
 
7
7
  - **キュー管理機能** - 複数の音声合成リクエストを効率的に処理
8
8
  - **プリフェッチ** - 次の音声を事前に生成し、再生をスムーズに
9
+ - **クロスプラットフォーム対応** - Windows、macOS で動作
10
+ - **マルチ環境対応** - Node.js(ライブラリ/CLI)とブラウザの環境で利用可能
11
+ - **ファイルダウンロード機能** - ブラウザ環境での音声ファイル保存をサポート
9
12
 
10
13
  ## 必要条件
11
14
 
12
15
  - Node.js
13
- - [VOICEVOXエンジン](https://voicevox.hiroshiba.jp/)
16
+ - [VOICEVOX エンジン](https://voicevox.hiroshiba.jp/)
14
17
 
15
18
  ## インストール
16
19
 
@@ -20,10 +23,10 @@ npm install -g @kajidog/mcp-tts-voicevox
20
23
 
21
24
  ## 使い方
22
25
 
23
- ### MCPサーバーとして
26
+ ### MCP サーバーとして
24
27
 
25
- 1. VOICEVOXエンジンを起動
26
- 2. MCPサーバーを起動
28
+ 1. VOICEVOX エンジンを起動
29
+ 2. MCP サーバーを起動
27
30
 
28
31
  ```bash
29
32
  npx @kajidog/mcp-tts-voicevox
@@ -37,14 +40,16 @@ npx @kajidog/mcp-tts-voicevox
37
40
  npm install @kajidog/mcp-tts-voicevox
38
41
  ```
39
42
 
43
+ #### Node.js 環境での使用例
44
+
40
45
  ```javascript
41
46
  import { VoicevoxClient } from "@kajidog/mcp-tts-voicevox";
42
47
 
43
48
  // クライアントを初期化
44
49
  const client = new VoicevoxClient({
45
50
  url: "http://localhost:50021", // VOICEVOXエンジンのURL
46
- defaultSpeaker: 1, // デフォルト話者ID(オプション)
47
- defaultSpeedScale: 1.0 // デフォルト速度(オプション)
51
+ defaultSpeaker: 1, // デフォルト話者ID(オプション)
52
+ defaultSpeedScale: 1.0, // デフォルト速度(オプション)
48
53
  });
49
54
 
50
55
  // テキストを音声に変換して再生
@@ -52,18 +57,90 @@ await client.speak("こんにちは");
52
57
 
53
58
  // テキストから音声ファイルを生成
54
59
  const filePath = await client.generateAudioFile("こんにちは", "./output.wav");
60
+
61
+ // キューをクリア
62
+ await client.clearQueue();
63
+
64
+ // スピーカー一覧を取得
65
+ const speakers = await client.getSpeakers();
66
+
67
+ // スピーカー詳細を取得
68
+ const speakerInfo = await client.getSpeakerInfo(speakers[0].speaker_uuid);
69
+ ```
70
+
71
+ #### ブラウザ環境での使用例
72
+
73
+ ```javascript
74
+ import { VoicevoxClient } from "@kajidog/mcp-tts-voicevox";
75
+
76
+ // クライアントを初期化(VOICEVOXエンジンが稼働しているURLを指定)
77
+ const client = new VoicevoxClient({
78
+ url: "http://localhost:50021",
79
+ defaultSpeaker: 1,
80
+ });
81
+
82
+ // ボタンクリックでテキストを音声に変換して再生
83
+ document.querySelector("#playButton").addEventListener("click", async () => {
84
+ await client.speak("こんにちは");
85
+ });
86
+
87
+ // ファイルダウンロードボタン
88
+ document
89
+ .querySelector("#downloadButton")
90
+ .addEventListener("click", async () => {
91
+ try {
92
+ // 音声ファイルを生成してダウンロード(ファイル名を指定)
93
+ const filename = `voice-${Date.now()}.wav`;
94
+ const result = await client.generateAudioFile("こんにちは", filename);
95
+ console.log("ダウンロードしたファイル:", result);
96
+ } catch (error) {
97
+ console.error("エラー:", error);
98
+ }
99
+ });
55
100
  ```
56
101
 
57
102
  ## 主な機能
58
103
 
59
104
  - **テキスト読み上げ** (`speak`) - テキストを音声に変換して再生
105
+ - **読み上げ停止** (`stop_speaker`) - 現在の音声合成キューをすべてクリア
60
106
  - **クエリ生成** (`generate_query`) - 音声合成用クエリの作成
61
107
  - **ファイル生成** (`synthesize_file`) - クエリから音声ファイルを生成
108
+ - **音声ファイルダウンロード** (`generateAudioFile`) - 音声ファイルを生成し、ブラウザでダウンロード
109
+ - **スピーカー一覧取得** (`get_speakers`) - 利用可能なスピーカー一覧を取得
110
+ - **スピーカー詳細取得** (`get_speaker_detail`) - スピーカー ID から詳細情報を取得
111
+
112
+ ## MCP 設定例
113
+
114
+ `mcp.json`ファイルまたは設定に以下のような設定を追加することで、MCP サーバーとして利用できます:
115
+
116
+ 例)ClaudeDesktop で AivisSpeech での設定例
117
+
118
+ ```json
119
+ {
120
+ "mcpServers": {
121
+ "tts-mcp": {
122
+ "command": "npx",
123
+ "args": ["-y", "@kajidog/mcp-tts-voicevox"],
124
+ "env": {
125
+ "VOICEVOX_URL": "http://127.0.0.1:10101",
126
+ "VOICEVOX_DEFAULT_SPEAKER": "888753764"
127
+ }
128
+ }
129
+ }
130
+ }
131
+ ```
62
132
 
63
133
  ## 環境変数
64
134
 
65
- - `VOICEVOX_URL`: VOICEVOXエンジンのURL(デフォルト: `http://localhost:50021`)
135
+ - `VOICEVOX_URL`: VOICEVOX エンジンの URL(デフォルト: `http://localhost:50021`)
136
+ - `VOICEVOX_DEFAULT_SPEAKER`: デフォルト話者 ID(例: `1`)
137
+ - `VOICEVOX_DEFAULT_SPEED_SCALE`: デフォルト再生速度(例: `1.0`)
138
+
139
+ ## ブラウザ互換性
140
+
141
+ - **Chrome, Firefox, Edge**: 完全対応
142
+ - **Safari**: ファイルダウンロードに特殊対応あり
66
143
 
67
144
  ## ライセンス
68
145
 
69
- ISC
146
+ ISC
@@ -0,0 +1,11 @@
1
+ /**
2
+ * MCP TTS Voicevox Client
3
+ * ライブラリとして使用するためのエントリーポイント
4
+ */
5
+ export { VoicevoxClient } from "./voicevox";
6
+ export { AudioQuery, VoicevoxConfig, VoicevoxError, Score, Note, FrameAudioQuery, } from "./voicevox/types";
7
+ export * from "./voicevox/queue";
8
+ export * from "./voicevox/api";
9
+ export * from "./voicevox/utils";
10
+ export { isBrowser } from "./voicevox/utils";
11
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAG5C,OAAO,EACL,UAAU,EACV,cAAc,EACd,aAAa,EACb,KAAK,EACL,IAAI,EACJ,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAG1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AAGjC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC"}
package/dist/client.js ADDED
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ /**
3
+ * MCP TTS Voicevox Client
4
+ * ライブラリとして使用するためのエントリーポイント
5
+ */
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
18
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.isBrowser = exports.VoicevoxError = exports.VoicevoxClient = void 0;
22
+ // クライアント
23
+ var voicevox_1 = require("./voicevox");
24
+ Object.defineProperty(exports, "VoicevoxClient", { enumerable: true, get: function () { return voicevox_1.VoicevoxClient; } });
25
+ // 型定義
26
+ var types_1 = require("./voicevox/types");
27
+ Object.defineProperty(exports, "VoicevoxError", { enumerable: true, get: function () { return types_1.VoicevoxError; } });
28
+ // 一部のコンポーネントを選択的に直接利用できるようにエクスポート
29
+ __exportStar(require("./voicevox/queue"), exports);
30
+ __exportStar(require("./voicevox/api"), exports);
31
+ __exportStar(require("./voicevox/utils"), exports);
32
+ // ブラウザ対応
33
+ var utils_1 = require("./voicevox/utils");
34
+ Object.defineProperty(exports, "isBrowser", { enumerable: true, get: function () { return utils_1.isBrowser; } });
35
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;AAEH,SAAS;AACT,uCAA4C;AAAnC,0GAAA,cAAc,OAAA;AAEvB,MAAM;AACN,0CAO0B;AAJxB,sGAAA,aAAa,OAAA;AAMf,kCAAkC;AAClC,mDAAiC;AACjC,iDAA+B;AAC/B,mDAAiC;AAEjC,SAAS;AACT,0CAA6C;AAApC,kGAAA,SAAS,OAAA"}
@@ -0,0 +1,2 @@
1
+ export * from "./client";
2
+ //# sourceMappingURL=index.browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.browser.d.ts","sourceRoot":"","sources":["../src/index.browser.ts"],"names":[],"mappings":"AAIA,cAAc,UAAU,CAAC"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ // MCP TTS Voicevox ブラウザエントリーポイント
3
+ // ブラウザ環境用の簡略化されたエントリーポイント
4
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
+ if (k2 === undefined) k2 = k;
6
+ var desc = Object.getOwnPropertyDescriptor(m, k);
7
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8
+ desc = { enumerable: true, get: function() { return m[k]; } };
9
+ }
10
+ Object.defineProperty(o, k2, desc);
11
+ }) : (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ o[k2] = m[k];
14
+ }));
15
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
17
+ };
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ // ライブラリとして使用する場合のエクスポート
20
+ __exportStar(require("./client"), exports);
21
+ // ログ出力は削除
22
+ //# sourceMappingURL=index.browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.browser.js","sourceRoot":"","sources":["../src/index.browser.ts"],"names":[],"mappings":";AAAA,iCAAiC;AACjC,0BAA0B;;;;;;;;;;;;;;;;AAE1B,wBAAwB;AACxB,2CAAyB;AAEzB,UAAU"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import { VoicevoxClient } from "./voicevox";
3
- import { AudioQuery, VoicevoxConfig, VoicevoxError, Score, Note, FrameAudioQuery } from "./voicevox/types";
4
- export { AudioQuery, VoicevoxConfig, VoicevoxClient, VoicevoxError, Score, Note, FrameAudioQuery, };
2
+ export * from "./client";
5
3
  //# sourceMappingURL=index.d.ts.map
@@ -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;AA4K1B,OAAO,EACL,UAAU,EACV,cAAc,EACd,cAAc,EACd,aAAa,EACb,KAAK,EACL,IAAI,EACJ,eAAe,GAChB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAKA,cAAc,UAAU,CAAC"}
package/dist/index.js CHANGED
@@ -1,133 +1,110 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.VoicevoxError = exports.VoicevoxClient = void 0;
5
- const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
6
- const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
7
- const zod_1 = require("zod");
8
- const voicevox_1 = require("./voicevox");
9
- Object.defineProperty(exports, "VoicevoxClient", { enumerable: true, get: function () { return voicevox_1.VoicevoxClient; } });
10
- const types_1 = require("./voicevox/types");
11
- Object.defineProperty(exports, "VoicevoxError", { enumerable: true, get: function () { return types_1.VoicevoxError; } });
12
- const server = new mcp_js_1.McpServer({
13
- name: "MCP TTS Voicevox",
14
- version: "0.0.8",
15
- description: "A Voicevox server that converts text to speech for playback and saving.",
16
- });
17
- // VoicevoxClientを一度だけインスタンス化
18
- const voicevoxClient = new voicevox_1.VoicevoxClient({
19
- url: process.env.VOICEVOX_URL ?? "http://localhost:50021",
20
- defaultSpeaker: Number(process.env.VOICEVOX_DEFAULT_SPEAKER || "1"),
21
- defaultSpeedScale: Number(process.env.VOICEVOX_DEFAULT_SPEED_SCALE || "1.0"),
3
+ // MCP TTS Voicevox エントリーポイント
4
+ // ライブラリとしても使用できるように、クライアントとCLIのエントリーポイントを分けて公開
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
22
20
  });
23
- // 共通のエラーハンドリング関数
24
- const handleError = (error) => {
25
- const errorMessage = error instanceof Error ? error.message : String(error);
26
- console.error("エラーが発生しました:", error);
27
- return {
28
- content: [{ type: "text", text: `エラー: ${errorMessage}` }],
21
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
22
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
23
+ };
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
29
39
  };
40
+ })();
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ // ライブラリとして使用する場合のエクスポート
43
+ __exportStar(require("./client"), exports);
44
+ // ブラウザ環境かどうかをチェックする関数
45
+ const isBrowser = () => {
46
+ return (typeof window !== "undefined" && typeof window.document !== "undefined");
30
47
  };
31
- // テキストを音声に変換して再生
32
- server.tool("speak", "Convert text to speech and play it", {
33
- text: zod_1.z
34
- .string()
35
- .describe("Text to be spoken (if both query and text are provided, query takes precedence)"),
36
- speaker: zod_1.z
37
- .number()
38
- .optional()
39
- .describe("Speaker ID (optional, used if text is provided)"),
40
- query: zod_1.z.string().optional().describe("Voice synthesis query"),
41
- speedScale: zod_1.z
42
- .number()
43
- .optional()
44
- .describe("Playback speed (optional, default is from environment variable)"),
45
- }, async ({ text, speaker, query, speedScale }) => {
48
+ // Node.js環境の場合のみCLI処理を実行
49
+ if (!isBrowser()) {
46
50
  try {
47
- if (query) {
48
- // クエリが提供されている場合はそれを使用
49
- const audioQuery = JSON.parse(query);
50
- if (speedScale !== undefined) {
51
- audioQuery.speedScale = speedScale;
51
+ // ファイルが直接実行された場合を検出する方法を改善
52
+ // process.envで実行モードを判定(CLIとして実行されているかどうかを確認)
53
+ const isCLI = typeof process !== "undefined" &&
54
+ !!((process.argv &&
55
+ process.argv.length > 1 && // コマンドライン引数がある
56
+ ((process.env && process.env.npm_lifecycle_event === "start") || // npm start で実行
57
+ process.argv[1]?.includes("mcp-tts-voicevox") || // NPXやバイナリ名で実行
58
+ process.argv[1]?.endsWith("dist/index.js") || // 直接JSファイルとして実行
59
+ process.argv[1]?.endsWith("src/index.ts"))) // ts-nodeなどで実行
60
+ );
61
+ // NPX経由で実行されたことを明示的に検出
62
+ const isNpx = typeof process !== "undefined" &&
63
+ !!(process.env &&
64
+ process.env.npm_execpath &&
65
+ process.argv[1] &&
66
+ !process.argv[1].includes("node_modules"));
67
+ if (isCLI || isNpx) {
68
+ // CLIモードで実行(ログ出力を削除)
69
+ // 同期的にstdioモジュールを読み込んで実行
70
+ try {
71
+ // ts-nodeや開発環境ではESモジュールとして読み込む
72
+ if (typeof process !== "undefined" &&
73
+ process.env &&
74
+ process.env.NODE_ENV === "development") {
75
+ Promise.resolve().then(() => __importStar(require("./stdio"))).catch(() => {
76
+ // エラーログを出力せずに終了
77
+ if (typeof process !== "undefined") {
78
+ process.exit(1);
79
+ }
80
+ });
81
+ }
82
+ else {
83
+ // 本番環境ではCommonJSとして読み込む
84
+ try {
85
+ // requireが利用可能な場合のみ実行
86
+ if (typeof require !== "undefined") {
87
+ require("./stdio");
88
+ }
89
+ }
90
+ catch (error) {
91
+ // エラーログを出力せずに終了
92
+ if (typeof process !== "undefined") {
93
+ process.exit(1);
94
+ }
95
+ }
96
+ }
52
97
  }
53
- const result = await voicevoxClient.enqueueAudioGeneration(audioQuery, speaker);
54
- return {
55
- content: [{ type: "text", text: result }],
56
- };
57
- }
58
- else {
59
- // テキストからの通常の発話
60
- const result = await voicevoxClient.speak(text, speaker, speedScale);
61
- return {
62
- content: [{ type: "text", text: result }],
63
- };
64
- }
65
- }
66
- catch (error) {
67
- return handleError(error);
68
- }
69
- });
70
- // クエリ生成ツール
71
- server.tool("generate_query", "Generate a query for voice synthesis", {
72
- text: zod_1.z.string().describe("Text for voice synthesis"),
73
- speaker: zod_1.z.number().optional().describe("Speaker ID (optional)"),
74
- speedScale: zod_1.z
75
- .number()
76
- .optional()
77
- .describe("Playback speed (optional, default is from environment variable)"),
78
- }, async ({ text, speaker, speedScale }) => {
79
- try {
80
- const query = await voicevoxClient.generateQuery(text, speaker, speedScale);
81
- return {
82
- content: [{ type: "text", text: JSON.stringify(query) }],
83
- };
84
- }
85
- catch (error) {
86
- return handleError(error);
87
- }
88
- });
89
- // 音声ファイル生成ツール
90
- server.tool("synthesize_file", "Generate an audio file and return its absolute path", {
91
- text: zod_1.z
92
- .string()
93
- .optional()
94
- .describe("Text for voice synthesis (if both query and text are provided, query takes precedence)"),
95
- query: zod_1.z.string().optional().describe("Voice synthesis query"),
96
- speaker: zod_1.z.number().optional().describe("Speaker ID (optional)"),
97
- output: zod_1.z.string().describe("Output path for the audio file"),
98
- speedScale: zod_1.z
99
- .number()
100
- .optional()
101
- .describe("Playback speed (optional, default is from environment variable)"),
102
- }, async ({ text, query, speaker, output, speedScale }) => {
103
- try {
104
- if (query) {
105
- // クエリが提供されている場合はそれを使用
106
- const audioQuery = JSON.parse(query);
107
- if (speedScale !== undefined) {
108
- audioQuery.speedScale = speedScale;
98
+ catch (error) {
99
+ // エラーログを出力せずに終了
100
+ if (typeof process !== "undefined") {
101
+ process.exit(1);
102
+ }
109
103
  }
110
- const filePath = await voicevoxClient.generateAudioFile(audioQuery, output, speaker);
111
- return {
112
- content: [{ type: "text", text: filePath }],
113
- };
114
- }
115
- else if (text) {
116
- // テキストから音声ファイルを生成
117
- const filePath = await voicevoxClient.generateAudioFile(text, output, speaker, speedScale);
118
- return {
119
- content: [{ type: "text", text: filePath }],
120
- };
121
- }
122
- else {
123
- throw new Error("queryパラメータとtextパラメータのどちらかを指定してください");
124
104
  }
125
105
  }
126
106
  catch (error) {
127
- return handleError(error);
107
+ // エラーを抑制(何もしない)
128
108
  }
129
- });
130
- server.connect(new stdio_js_1.StdioServerTransport()).catch((error) => {
131
- console.error("Error connecting to MCP transport:", error);
132
- process.exit(1);
133
- });
109
+ }
110
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AACA,6BAA6B;AAC7B,+CAA+C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE/C,wBAAwB;AACxB,2CAAyB;AAEzB,sBAAsB;AACtB,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,OAAO,CACL,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,WAAW,CACxE,CAAC;AACJ,CAAC,CAAC;AAEF,yBAAyB;AACzB,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC;IACjB,IAAI,CAAC;QACH,2BAA2B;QAC3B,6CAA6C;QAC7C,MAAM,KAAK,GACT,OAAO,OAAO,KAAK,WAAW;YAC9B,CAAC,CAAC,CACA,CACE,OAAO,CAAC,IAAI;gBACZ,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,eAAe;gBAC1C,CAAC,CAAC,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,mBAAmB,KAAK,OAAO,CAAC,IAAI,gBAAgB;oBAC/E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,kBAAkB,CAAC,IAAI,eAAe;oBAChE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,eAAe,CAAC,IAAI,gBAAgB;oBAC9D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC,CAC7C,CAAC,eAAe;aAClB,CAAC;QAEJ,uBAAuB;QACvB,MAAM,KAAK,GACT,OAAO,OAAO,KAAK,WAAW;YAC9B,CAAC,CAAC,CACA,OAAO,CAAC,GAAG;gBACX,OAAO,CAAC,GAAG,CAAC,YAAY;gBACxB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;gBACf,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,cAAc,CAAC,CAC1C,CAAC;QAEJ,IAAI,KAAK,IAAI,KAAK,EAAE,CAAC;YACnB,qBAAqB;YAErB,yBAAyB;YACzB,IAAI,CAAC;gBACH,+BAA+B;gBAC/B,IACE,OAAO,OAAO,KAAK,WAAW;oBAC9B,OAAO,CAAC,GAAG;oBACX,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,EACtC,CAAC;oBACD,kDAAO,SAAS,IAAE,KAAK,CAAC,GAAG,EAAE;wBAC3B,gBAAgB;wBAChB,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE,CAAC;4BACnC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;wBAClB,CAAC;oBACH,CAAC,CAAC,CAAC;gBACL,CAAC;qBAAM,CAAC;oBACN,wBAAwB;oBACxB,IAAI,CAAC;wBACH,sBAAsB;wBACtB,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE,CAAC;4BACnC,OAAO,CAAC,SAAS,CAAC,CAAC;wBACrB,CAAC;oBACH,CAAC;oBAAC,OAAO,KAAK,EAAE,CAAC;wBACf,gBAAgB;wBAChB,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE,CAAC;4BACnC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;wBAClB,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,gBAAgB;gBAChB,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE,CAAC;oBACnC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAClB,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,gBAAgB;IAClB,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=stdio.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stdio.d.ts","sourceRoot":"","sources":["../src/stdio.ts"],"names":[],"mappings":""}