Spaces:
Paused
Paused
update index page
Browse files
api.py
CHANGED
|
@@ -6,6 +6,7 @@ from typing import Optional
|
|
| 6 |
from fastapi import FastAPI, File, UploadFile, HTTPException, Depends
|
| 7 |
from fastapi.middleware.cors import CORSMiddleware
|
| 8 |
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
|
|
|
|
| 9 |
import numpy as np
|
| 10 |
import torch
|
| 11 |
import torchaudio
|
|
@@ -251,6 +252,41 @@ async def transcribe_audio(
|
|
| 251 |
raise HTTPException(status_code=500, detail=str(e))
|
| 252 |
|
| 253 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 254 |
if __name__ == "__main__":
|
| 255 |
import uvicorn
|
| 256 |
uvicorn.run(app, host="0.0.0.0", port=8000)
|
|
|
|
| 6 |
from fastapi import FastAPI, File, UploadFile, HTTPException, Depends
|
| 7 |
from fastapi.middleware.cors import CORSMiddleware
|
| 8 |
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
|
| 9 |
+
from fastapi.responses import HTMLResponse
|
| 10 |
import numpy as np
|
| 11 |
import torch
|
| 12 |
import torchaudio
|
|
|
|
| 252 |
raise HTTPException(status_code=500, detail=str(e))
|
| 253 |
|
| 254 |
|
| 255 |
+
@app.get("/", response_class=HTMLResponse)
|
| 256 |
+
async def root():
|
| 257 |
+
html_content = """
|
| 258 |
+
<!DOCTYPE html>
|
| 259 |
+
<html>
|
| 260 |
+
<head>
|
| 261 |
+
<title>SenseVoice API</title>
|
| 262 |
+
<style>
|
| 263 |
+
body { font-family: Arial, sans-serif; max-width: 800px; margin: 40px auto; padding: 0 20px; line-height: 1.6; }
|
| 264 |
+
h1 { color: #2c3e50; }
|
| 265 |
+
.api-info { background: #f8f9fa; padding: 20px; border-radius: 5px; margin: 20px 0; }
|
| 266 |
+
.api-link { display: inline-block; background: #3498db; color: white; padding: 10px 20px; text-decoration: none; border-radius: 5px; margin-top: 20px; }
|
| 267 |
+
.api-link:hover { background: #2980b9; }
|
| 268 |
+
</style>
|
| 269 |
+
</head>
|
| 270 |
+
<body>
|
| 271 |
+
<h1>欢迎使用 SenseVoice API</h1>
|
| 272 |
+
<div class="api-info">
|
| 273 |
+
<h2>服务信息</h2>
|
| 274 |
+
<p>版本:1.0.0</p>
|
| 275 |
+
<p>描述:多语言语音识别服务,支持中文、英语、粤语、日语、韩语等多种语言的语音转写。</p>
|
| 276 |
+
<h2>主要功能</h2>
|
| 277 |
+
<ul>
|
| 278 |
+
<li>支持多种音频格式:MP3、WAV、FLAC、OGG、M4A</li>
|
| 279 |
+
<li>自动语言检测</li>
|
| 280 |
+
<li>情感和事件识别</li>
|
| 281 |
+
<li>高性能语音识别引擎</li>
|
| 282 |
+
</ul>
|
| 283 |
+
</div>
|
| 284 |
+
<a href="/docs" class="api-link">查看API文档</a>
|
| 285 |
+
</body>
|
| 286 |
+
</html>
|
| 287 |
+
"""
|
| 288 |
+
return html_content
|
| 289 |
+
|
| 290 |
if __name__ == "__main__":
|
| 291 |
import uvicorn
|
| 292 |
uvicorn.run(app, host="0.0.0.0", port=8000)
|