File size: 708 Bytes
89e06c9
859e0c0
fdc50d3
89e06c9
 
859e0c0
 
 
 
 
fdc50d3
 
 
 
 
 
 
 
859e0c0
2868142
 
 
 
3cbb3d6
fdc50d3
 
 
2c102cf
40e4e46
 
859e0c0
0ab5bef
5e659fa
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
from fastapi import FastAPI, UploadFile
from pydantic import BaseModel
from .audio_handler import audio_handler, audio_url_handler


class URL(BaseModel):
    url: str
    from_lang: str | None = None
    to_lang: str | None = None

class Audio(BaseModel):
    file: UploadFile
    from_lang: str | None = None
    to_lang: str | None = None


app = FastAPI()


@app.get("/")
async def main():
    return {"health_check": "OK"}

@app.post("/")
async def main(audio: Audio):
    response = audio_handler(audio.file, audio.from_lang, audio.to_lang)
    return response

    
@app.post("/url")
async def url(url: URL):
    response = audio_url_handler(url.url, url.from_lang, url.to_lang)
    return response