File size: 2,556 Bytes
4a13628
c7fc3b6
 
4a13628
c7fc3b6
4a13628
 
95cb26e
4a13628
 
 
 
 
c7fc3b6
 
95cb26e
c7fc3b6
 
 
 
4a13628
 
c7fc3b6
4a13628
9aa985d
4a13628
 
 
 
 
 
 
 
c7fc3b6
 
4a13628
 
95cb26e
 
4a13628
 
 
 
c7fc3b6
 
95cb26e
 
4a13628
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95cb26e
4a13628
 
 
 
 
 
95cb26e
c7fc3b6
918acab
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
from pydantic import BaseModel, Field
from typing import Optional


class STTResponse(BaseModel):
    """Response model for Speech-to-Text"""
    text: str = Field(..., description="Transcribed text from audio")
    model_name: str = Field(default="whisper-small", description="Model used")
    language: Optional[str] = Field(default="en", description="Detected language")
    duration_seconds: Optional[float] = Field(None, description="Audio duration")
    
    class Config:
        json_schema_extra = {
            "example": {
                "text": "hello how are you",
                "model_name": "whisper-small",
                "language": "en",
                "duration_seconds": 3.2
            }
        }


class TTSRequest(BaseModel):
    """Request model for Text-to-Speech"""
    text: str = Field(..., min_length=1, max_length=500, description="Text to convert to speech")
    
    class Config:
        json_schema_extra = {
            "example": {
                "text": "Hello, welcome to our AI voice system."
            }
        }


class TTSResponse(BaseModel):
    """Response model for Text-to-Speech"""
    message: str = Field(..., description="Status message")
    audio_format: str = Field(default="mp3", description="Audio format")
    model_name: str = Field(default="gTTS", description="Model used")
    length_seconds: Optional[float] = Field(None, description="Generated audio duration")
    
    class Config:
        json_schema_extra = {
            "example": {
                "message": "Audio generated successfully",
                "audio_format": "mp3",
                "model_name": "gTTS",
                "length_seconds": 2.5
            }
        }


class ChatbotRequest(BaseModel):
    """Request model for Chatbot"""
    text: str = Field(..., min_length=1, max_length=500, description="User query")
    
    class Config:
        json_schema_extra = {
            "example": {
                "text": "What is the weather today?"
            }
        }


class ChatbotResponse(BaseModel):
    """Response model for Chatbot"""
    user_input: str = Field(..., description="User input text")
    bot_response: str = Field(..., description="Bot response text")
    model_name: str = Field(default="DialoGPT-medium", description="Model used")
    
    class Config:
        json_schema_extra = {
            "example": {
                "user_input": "Hello",
                "bot_response": "Hi there! How can I help you?",
                "model_name": "DialoGPT-medium"
            }
        }