Skip to content

Commit 45502e3

Browse files
[Penify]: Documentation for commit - ea03621
1 parent 370de53 commit 45502e3

1 file changed

Lines changed: 8 additions & 24 deletions

File tree

main.py

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,15 @@ def __init__(self):
3333
self.speech = SpeechProcessor()
3434

3535
def process_nlp(self, prompt: str) -> str:
36-
"""
37-
Processes text using the NLP module.
38-
"""
36+
"""Processes text using the NLP module."""
3937
return self.nlp.generate_text(prompt)
4038

4139
def process_cv(self, image: Image.Image) -> str:
42-
"""
43-
Processes an image using the CV module.
44-
"""
40+
"""Processes an image to detect objects using the CV module."""
4541
return self.cv.detect_objects(image)
4642

4743
def process_stt(self, file: UploadFile) -> str:
48-
"""
49-
Processes audio using the STT module.
50-
"""
44+
"""Processes audio and converts it to text using the STT module."""
5145
return self.speech.speech_to_text(file)
5246

5347
def process_tts(self, text: str) -> None:
@@ -62,18 +56,14 @@ def process_tts(self, text: str) -> None:
6256

6357

6458
def verify_token(credentials: HTTPAuthorizationCredentials = Depends(security)):
65-
"""
66-
Verifies the Bearer token in the Authorization header.
67-
"""
59+
"""Verifies the Bearer token in the Authorization header."""
6860
if credentials.credentials != VALID_API_KEY:
6961
raise HTTPException(status_code=403, detail="Forbidden")
7062

7163

7264
@app.post("/process-nlp/", dependencies=[Depends(verify_token)])
7365
async def process_nlp(data: dict):
74-
"""
75-
Endpoint for text generation.
76-
"""
66+
"""Processes natural language input and generates a response."""
7767
try:
7868
prompt = data.get("text", "")
7969
return {"response": agi.process_nlp(prompt)}
@@ -84,9 +74,7 @@ async def process_nlp(data: dict):
8474

8575
@app.post("/process-cv-detection/", dependencies=[Depends(verify_token)])
8676
async def process_cv_detection(file: UploadFile = File(...)):
87-
"""
88-
Endpoint for object detection in images.
89-
"""
77+
"""Handles object detection in uploaded images."""
9078
try:
9179
image_data = await file.read()
9280
image = Image.open(BytesIO(image_data))
@@ -98,9 +86,7 @@ async def process_cv_detection(file: UploadFile = File(...)):
9886

9987
@app.post("/speech-to-text/", dependencies=[Depends(verify_token)])
10088
async def speech_to_text(file: UploadFile = File(...)):
101-
"""
102-
Endpoint for Speech-to-Text conversion.
103-
"""
89+
"""Converts speech from an uploaded file to text."""
10490
try:
10591
return {"response": agi.process_stt(file)}
10692
except Exception as e:
@@ -110,9 +96,7 @@ async def speech_to_text(file: UploadFile = File(...)):
11096

11197
@app.post("/text-to-speech/", dependencies=[Depends(verify_token)])
11298
async def text_to_speech(data: dict):
113-
"""
114-
Endpoint for Text-to-Speech conversion.
115-
"""
99+
"""Converts text to speech."""
116100
try:
117101
text = data.get("text", "")
118102
agi.process_tts(text)

0 commit comments

Comments
 (0)