|
3 | 3 | import datetime
|
4 | 4 | import os
|
5 | 5 | from pathlib import Path
|
6 |
| -from typing import Any |
| 6 | +from typing import Annotated, Any |
7 | 7 |
|
8 | 8 | import whisper
|
9 | 9 | from loguru import logger
|
| 10 | +from pydantic import Field |
10 | 11 |
|
11 | 12 | from mcp_toolbox.app import mcp
|
12 | 13 |
|
@@ -77,10 +78,10 @@ def load_audio(audio_path, model_name="base"):
|
77 | 78 | return _audio
|
78 | 79 |
|
79 | 80 |
|
80 |
| -@mcp.tool( |
81 |
| - description="Get the length of an audio file in seconds. Args: audio_path (required, The path to the audio file)" |
82 |
| -) |
83 |
| -async def get_audio_length(audio_path: str) -> dict[str, Any]: |
| 81 | +@mcp.tool(description="Get the length of an audio file in seconds.") |
| 82 | +async def get_audio_length( |
| 83 | + audio_path: Annotated[str, Field(description="The path to the audio file")], |
| 84 | +) -> dict[str, Any]: |
84 | 85 | """Get the length of an audio file in seconds.
|
85 | 86 |
|
86 | 87 | Args:
|
@@ -112,11 +113,14 @@ async def get_audio_length(audio_path: str) -> dict[str, Any]:
|
112 | 113 | }
|
113 | 114 |
|
114 | 115 |
|
115 |
| -@mcp.tool( |
116 |
| - description="Get transcribed text from a specific time range in an audio file. Args: audio_path (required, The path to the audio file), start_time (required, Start time in seconds), end_time (required, End time in seconds), model_name (optional, Whisper model name: tiny, base, small, medium, large)" |
117 |
| -) |
| 116 | +@mcp.tool(description="Get transcribed text from a specific time range in an audio file.") |
118 | 117 | async def get_audio_text(
|
119 |
| - audio_path: str, start_time: float, end_time: float, model_name: str = "base" |
| 118 | + audio_path: Annotated[str, Field(description="The path to the audio file")], |
| 119 | + start_time: Annotated[float, Field(description="Start time in seconds")], |
| 120 | + end_time: Annotated[float, Field(description="End time in seconds")], |
| 121 | + model_name: Annotated[ |
| 122 | + str, Field(default="base", description="Whisper model name: tiny, base, small, medium, large") |
| 123 | + ] = "base", |
120 | 124 | ) -> dict[str, Any]:
|
121 | 125 | """Extract and transcribe text from a specific time range in an audio file.
|
122 | 126 |
|
|
0 commit comments