tuan243 commited on
Commit
ee42cb0
·
verified ·
1 Parent(s): 92a31f2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -8
app.py CHANGED
@@ -2,19 +2,19 @@ from fastapi import FastAPI, File, UploadFile
2
  import librosa
3
  import numpy as np
4
  import shutil
5
- from funasr import AutoModel
6
- from funasr.utils.postprocess_utils import rich_transcription_postprocess
7
-
8
- from funasr.auto.auto_model import AutoModel
9
  import os
 
10
 
11
-
12
  app = FastAPI()
13
 
14
- # Load hình SenseVoiceSmall
15
- model_dir = "FunAudioLLM/SenseVoiceSmall"
16
-
17
 
 
 
18
  model = AutoModel(
19
  model=model_dir,
20
  vad_model="fsmn-vad",
@@ -52,3 +52,7 @@ async def detect_noise_api(file: UploadFile = File(...)):
52
 
53
  result = detect_noise(file_path)
54
  return {"noise_level": result}
 
 
 
 
 
2
  import librosa
3
  import numpy as np
4
  import shutil
5
+ import uvicorn
 
 
 
6
  import os
7
+ from funasr import AutoModel
8
 
9
+ # Khởi tạo FastAPI
10
  app = FastAPI()
11
 
12
+ # Tạo thư mục temp nếu chưa có
13
+ if not os.path.exists("temp"):
14
+ os.makedirs("temp")
15
 
16
+ # Load mô hình SenseVoiceSmall từ Hugging Face
17
+ model_dir = "FunAudioLLM/SenseVoiceSmall"
18
  model = AutoModel(
19
  model=model_dir,
20
  vad_model="fsmn-vad",
 
52
 
53
  result = detect_noise(file_path)
54
  return {"noise_level": result}
55
+
56
+ # Chạy FastAPI trên Hugging Face Spaces
57
+ if __name__ == "__main__":
58
+ uvicorn.run(app, host="0.0.0.0", port=7860)