maylinejix commited on
Commit
dc559ef
Β·
verified Β·
1 Parent(s): e7cf803

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -9
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import whisper
2
  import tempfile
3
  import os
 
4
  from fastapi import FastAPI, UploadFile, File, Form
5
  from fastapi.responses import JSONResponse, HTMLResponse
6
  from fastapi.middleware.cors import CORSMiddleware
@@ -38,16 +39,11 @@ async def root():
38
  <p>Status: <strong style="color:#7fff7f">Running</strong></p>
39
  <p>Endpoints:</p>
40
  <ul>
41
- <li><code>POST /transcribe</code> β€” Upload audio file, returns text</li>
 
42
  <li><code>GET /health</code> β€” Health check</li>
43
  <li><a href="/docs">πŸ“– Swagger Docs</a></li>
44
  </ul>
45
- <p>Example curl:</p>
46
- <pre style="background:#1a1a1a;padding:16px;border-radius:8px;">
47
- curl -X POST /transcribe \\
48
- -F "file=@audio.wav" \\
49
- -F "language=auto"
50
- </pre>
51
  </body>
52
  </html>
53
  """
@@ -83,7 +79,7 @@ async def transcribe(
83
  finally:
84
  os.unlink(tmp_path)
85
 
86
- @app.post("/transcribe-url")
87
  async def transcribe_url(
88
  url: str = Form(...),
89
  language: str = Form(default="auto")
@@ -125,4 +121,4 @@ async def health():
125
  return {"status": "ok", "model": "whisper-base"}
126
 
127
  if __name__ == "__main__":
128
- uvicorn.run(app, host="0.0.0.0", port=7860)
 
1
  import whisper
2
  import tempfile
3
  import os
4
+ import httpx
5
  from fastapi import FastAPI, UploadFile, File, Form
6
  from fastapi.responses import JSONResponse, HTMLResponse
7
  from fastapi.middleware.cors import CORSMiddleware
 
39
  <p>Status: <strong style="color:#7fff7f">Running</strong></p>
40
  <p>Endpoints:</p>
41
  <ul>
42
+ <li><code>POST /transcribe</code> β€” Upload audio file</li>
43
+ <li><code>POST /transcribe-url</code> β€” Transcribe from URL</li>
44
  <li><code>GET /health</code> β€” Health check</li>
45
  <li><a href="/docs">πŸ“– Swagger Docs</a></li>
46
  </ul>
 
 
 
 
 
 
47
  </body>
48
  </html>
49
  """
 
79
  finally:
80
  os.unlink(tmp_path)
81
 
82
+ @app.post("/transcribe-url")
83
  async def transcribe_url(
84
  url: str = Form(...),
85
  language: str = Form(default="auto")
 
121
  return {"status": "ok", "model": "whisper-base"}
122
 
123
  if __name__ == "__main__":
124
+ uvicorn.run(app, host="0.0.0.0", port=7860)