get_voices_in_use
Retrieve currently active voice IDs across all VOICEVOX processes to monitor voice usage and prevent assignment conflicts.
Instructions
現在使用中の音声IDのリストを取得(全プロセス共通)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/shared-state.ts:150-169 (handler)Main handler implementation of getVoicesInUse. Acquires lock, reads shared state, cleans up old entries, and returns unique voice IDs currently in use across all processes.
async getVoicesInUse(): Promise<number[]> { const locked = await this.acquireLock(); if (!locked) { // ロックが取得できない場合でも読み取りは試みる const state = await this.readState(); const cleanedState = this.cleanupOldEntries(state); return [...new Set(cleanedState.entries.map((e) => e.voiceId))]; } try { let state = await this.readState(); state = this.cleanupOldEntries(state); await this.writeState(state); // クリーンアップ後の状態を保存 // 重複を除いた音声IDのリストを返す return [...new Set(state.entries.map((e) => e.voiceId))]; } finally { await this.releaseLock(); } } - src/index.ts:114-121 (registration)Tool registration defining the get_voices_in_use tool with its name, description (Japanese), and empty input schema.
{ name: "get_voices_in_use", description: "現在使用中の音声IDのリストを取得(全プロセス共通)", inputSchema: { type: "object", properties: {}, }, }, - src/index.ts:227-240 (registration)Case handler that routes get_voices_in_use tool calls to queue.getVoicesInUse() and formats the response with voices list and count.
case "get_voices_in_use": { const voicesInUse = await queue.getVoicesInUse(); return { content: [ { type: "text", text: JSON.stringify({ voicesInUse, count: voicesInUse.length, }, null, 2), }, ], }; } - src/queue.ts:73-89 (helper)Intermediate wrapper that calls sharedState.getVoicesInUse() with error handling and fallback to local queue voices.
async getVoicesInUse(): Promise<number[]> { // 共有状態から全プロセスの使用中音声を取得 try { return await this.sharedState.getVoicesInUse(); } catch (error) { console.error("Failed to get voices in use:", error); // エラー時はローカルのキュー情報のみ返す const localVoices: number[] = []; if (this.currentTask) { localVoices.push(this.currentTask.voiceId); } this.tasks.forEach((task) => { localVoices.push(task.voiceId); }); return [...new Set(localVoices)]; } }