Update app.py
Browse files
app.py
CHANGED
@@ -17,10 +17,19 @@ templates = Jinja2Templates(directory="templates")
|
|
17 |
async def index(request: Request):
|
18 |
return templates.TemplateResponse("index.html", {"request": request})
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
@app.post("/transcribe")
|
21 |
async def transcribe_audio(audio_data: UploadFile = File(...), language: str = Form(...)):
|
22 |
try:
|
|
|
23 |
audio_content = await audio_data.read()
|
|
|
|
|
24 |
# Transcribe the audio based on the selected language
|
25 |
transcription = client.audio.transcriptions.create(
|
26 |
file=(audio_data.filename, audio_content),
|
@@ -30,9 +39,11 @@ async def transcribe_audio(audio_data: UploadFile = File(...), language: str = F
|
|
30 |
language=language,
|
31 |
)
|
32 |
|
|
|
33 |
return JSONResponse(content={'transcription': transcription})
|
34 |
|
35 |
except Exception as e:
|
|
|
36 |
return JSONResponse(status_code=500, content={'error': str(e)})
|
37 |
|
38 |
@app.post("/check_grammar")
|
|
|
17 |
async def index(request: Request):
|
18 |
return templates.TemplateResponse("index.html", {"request": request})
|
19 |
|
20 |
+
import logging
|
21 |
+
|
22 |
+
# Set up basic logging
|
23 |
+
logging.basicConfig(level=logging.DEBUG)
|
24 |
+
logger = logging.getLogger(__name__)
|
25 |
+
|
26 |
@app.post("/transcribe")
|
27 |
async def transcribe_audio(audio_data: UploadFile = File(...), language: str = Form(...)):
|
28 |
try:
|
29 |
+
logger.debug(f"Received audio file: {audio_data.filename} with language: {language}")
|
30 |
audio_content = await audio_data.read()
|
31 |
+
logger.debug(f"Audio content length: {len(audio_content)}")
|
32 |
+
|
33 |
# Transcribe the audio based on the selected language
|
34 |
transcription = client.audio.transcriptions.create(
|
35 |
file=(audio_data.filename, audio_content),
|
|
|
39 |
language=language,
|
40 |
)
|
41 |
|
42 |
+
logger.debug(f"Transcription result: {transcription}")
|
43 |
return JSONResponse(content={'transcription': transcription})
|
44 |
|
45 |
except Exception as e:
|
46 |
+
logger.error(f"Error during transcription: {e}")
|
47 |
return JSONResponse(status_code=500, content={'error': str(e)})
|
48 |
|
49 |
@app.post("/check_grammar")
|