Spaces:
Running
Running
feat: add Wav2Vec2 detector service to analysis route
Browse files- app/routes/analyze.py +7 -1
app/routes/analyze.py
CHANGED
|
@@ -39,6 +39,7 @@ from ..services.vocal_analyzer import (
|
|
| 39 |
from ..services.score_fusion import fuse_scores, FusionResult
|
| 40 |
from ..services.clap_detector import CLAPDetectorService
|
| 41 |
from ..services.fst_client import FSTClientService
|
|
|
|
| 42 |
from ..services.inference_xai import get_xai_service
|
| 43 |
from ..services.logging_config import get_logger
|
| 44 |
|
|
@@ -83,6 +84,7 @@ youtube_service = YouTubeAnalysisService()
|
|
| 83 |
preview_model = PreviewModel()
|
| 84 |
clap_service = CLAPDetectorService()
|
| 85 |
fst_service = FSTClientService()
|
|
|
|
| 86 |
xai_service = get_xai_service()
|
| 87 |
|
| 88 |
# Thread pool for CPU-bound audio analysis (feature extraction + vocal)
|
|
@@ -335,7 +337,7 @@ async def _analyze_file(
|
|
| 335 |
warnings: List[str] = []
|
| 336 |
loop = asyncio.get_event_loop()
|
| 337 |
|
| 338 |
-
# ── Run feature extraction + vocal analysis + CLAP in parallel ──
|
| 339 |
def _extract_features_sync():
|
| 340 |
return extract_features(io.BytesIO(content))
|
| 341 |
|
|
@@ -345,9 +347,13 @@ async def _analyze_file(
|
|
| 345 |
def _clap_predict_sync():
|
| 346 |
return clap_service.predict(io.BytesIO(content))
|
| 347 |
|
|
|
|
|
|
|
|
|
|
| 348 |
feat_future = loop.run_in_executor(_analysis_pool, _extract_features_sync)
|
| 349 |
vocal_future = loop.run_in_executor(_analysis_pool, _analyze_vocals_sync)
|
| 350 |
clap_future = loop.run_in_executor(_analysis_pool, _clap_predict_sync)
|
|
|
|
| 351 |
|
| 352 |
# Await feature extraction first (required for fusion)
|
| 353 |
try:
|
|
|
|
| 39 |
from ..services.score_fusion import fuse_scores, FusionResult
|
| 40 |
from ..services.clap_detector import CLAPDetectorService
|
| 41 |
from ..services.fst_client import FSTClientService
|
| 42 |
+
from ..services.wav2vec2_detector import Wav2Vec2DetectorService
|
| 43 |
from ..services.inference_xai import get_xai_service
|
| 44 |
from ..services.logging_config import get_logger
|
| 45 |
|
|
|
|
| 84 |
preview_model = PreviewModel()
|
| 85 |
clap_service = CLAPDetectorService()
|
| 86 |
fst_service = FSTClientService()
|
| 87 |
+
wav2vec2_service = Wav2Vec2DetectorService()
|
| 88 |
xai_service = get_xai_service()
|
| 89 |
|
| 90 |
# Thread pool for CPU-bound audio analysis (feature extraction + vocal)
|
|
|
|
| 337 |
warnings: List[str] = []
|
| 338 |
loop = asyncio.get_event_loop()
|
| 339 |
|
| 340 |
+
# ── Run feature extraction + vocal analysis + CLAP + wav2vec2 in parallel ──
|
| 341 |
def _extract_features_sync():
|
| 342 |
return extract_features(io.BytesIO(content))
|
| 343 |
|
|
|
|
| 347 |
def _clap_predict_sync():
|
| 348 |
return clap_service.predict(io.BytesIO(content))
|
| 349 |
|
| 350 |
+
def _wav2vec2_predict_sync():
|
| 351 |
+
return wav2vec2_service.predict(io.BytesIO(content))
|
| 352 |
+
|
| 353 |
feat_future = loop.run_in_executor(_analysis_pool, _extract_features_sync)
|
| 354 |
vocal_future = loop.run_in_executor(_analysis_pool, _analyze_vocals_sync)
|
| 355 |
clap_future = loop.run_in_executor(_analysis_pool, _clap_predict_sync)
|
| 356 |
+
wav2vec2_future = loop.run_in_executor(_analysis_pool, _wav2vec2_predict_sync)
|
| 357 |
|
| 358 |
# Await feature extraction first (required for fusion)
|
| 359 |
try:
|