| from pydantic import BaseModel, Field | |
| from typing import Optional | |
| class STTResponse(BaseModel): | |
| text: str = Field(..., description="Transcribed text") | |
| model_name: str = Field(default="whisper-base", description="Model used") | |
| language: Optional[str] = Field(default="en", description="Language detected") | |
| duration_seconds: Optional[float] = Field(None, description="Audio duration") | |
| class Config: | |
| json_schema_extra = { | |
| "example": { | |
| "text": "hello how are you", | |
| "model_name": "whisper-base", | |
| "language": "en", | |
| "duration_seconds": 3.2 | |
| } | |
| } | |
| class TTSRequest(BaseModel): | |
| text: str = Field(..., min_length=1, max_length=500, description="Text to convert") | |
| class Config: | |
| json_schema_extra = {"example": {"text": "Hello world"}} | |
| class ChatbotRequest(BaseModel): | |
| text: str = Field(..., min_length=1, max_length=500, description="User input") | |
| class Config: | |
| json_schema_extra = {"example": {"text": "What is AI?"}} | |
| class ChatbotResponse(BaseModel): | |
| user_input: str | |
| bot_response: str | |
| model_name: str = Field(default="DialoGPT-medium") | |
| class Config: | |
| json_schema_extra = { | |
| "example": { | |
| "user_input": "Hello", | |
| "bot_response": "Hi there! How can I help?", | |
| "model_name": "DialoGPT-medium" | |
| } | |
| } | |