human_ear_tool
Analyze and interpret environmental sounds, identify specific audio sources, and transcribe conversations by leveraging human auditory capabilities within the human-mcp server. Submit instructions to receive detailed audio insights.
Instructions
人間が耳を使って音を聞き、状況を説明します。
例:
- 周囲の環境音の確認
- 特定の音源の識別
- 会話の聞き取り
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| instruction | Yes |
Implementation Reference
- human_mcp/mcp_server.py:123-147 (handler)The primary handler function for the 'human_ear_tool'. Decorated with @mcp.tool() for automatic registration with the MCP server. It creates a database task with the formatted instruction, asynchronously waits for human completion via polling, and returns the result as {'sound': result}.@mcp.tool() async def human_ear_tool(instruction: str, ctx: Context) -> Dict[str, str]: """人間が耳を使って音を聞き、状況を説明します。 例: - 周囲の環境音の確認 - 特定の音源の識別 - 会話の聞き取り """ task_id = str(uuid.uuid4()) formatted_instruction = f"👂 耳を使って聴取: {instruction}" # タスクをデータベースに追加 db_utils.add_task(task_id, formatted_instruction) # ログ出力 sys.stderr.write(f"Human task created: {task_id}. Waiting for completion...\n") # 結果を待機(非同期ポーリング) result = await wait_for_task_completion(task_id) # ログ出力 sys.stderr.write(f"Human task {task_id} completed.\n") return {"sound": result}
- human_mcp/mcp_server.py:201-219 (helper)Helper function used by human_ear_tool (and other tools) to poll the database for task completion with a 300-second timeout.async def wait_for_task_completion(task_id: str, timeout: int = 300) -> str: """タスクの完了を待機する(タイムアウト付き)""" start_time = asyncio.get_event_loop().time() while True: # 現在の経過時間を確認 elapsed = asyncio.get_event_loop().time() - start_time if elapsed > timeout: return f"タイムアウト: {timeout}秒経過しても応答がありませんでした。" # タスクの状態を確認 status, result = db_utils.get_task_result(task_id) if status == 'completed' and result is not None: return result # 1秒待機してから再確認 await asyncio.sleep(1)