Update app.py
Browse files
app.py
CHANGED
|
@@ -2,21 +2,21 @@ import gradio as gr
|
|
| 2 |
import librosa
|
| 3 |
import numpy as np
|
| 4 |
import torch
|
| 5 |
-
from transformers import
|
| 6 |
import tempfile
|
| 7 |
import soundfile as sf
|
| 8 |
import json
|
| 9 |
|
| 10 |
SAMPLE_RATE = 16000
|
| 11 |
-
CHUNK_SIZE = 60
|
| 12 |
-
STEP = 10
|
| 13 |
MUSIC_THRESHOLD = 0.5
|
| 14 |
VOICE_THRESHOLD = 0.3
|
| 15 |
-
MIN_SEG_DURATION = 8
|
| 16 |
|
| 17 |
-
# ===
|
| 18 |
music_model_id = "AI-Music-Detection/ai_music_detection_large_60s"
|
| 19 |
-
|
| 20 |
music_model = AutoModelForAudioClassification.from_pretrained(music_model_id)
|
| 21 |
|
| 22 |
voice_model_id = "superb/hubert-large-superb-sid"
|
|
|
|
| 2 |
import librosa
|
| 3 |
import numpy as np
|
| 4 |
import torch
|
| 5 |
+
from transformers import AutoFeatureExtractor, AutoModelForAudioClassification
|
| 6 |
import tempfile
|
| 7 |
import soundfile as sf
|
| 8 |
import json
|
| 9 |
|
| 10 |
SAMPLE_RATE = 16000
|
| 11 |
+
CHUNK_SIZE = 60
|
| 12 |
+
STEP = 10
|
| 13 |
MUSIC_THRESHOLD = 0.5
|
| 14 |
VOICE_THRESHOLD = 0.3
|
| 15 |
+
MIN_SEG_DURATION = 8
|
| 16 |
|
| 17 |
+
# === 修正版 ===
|
| 18 |
music_model_id = "AI-Music-Detection/ai_music_detection_large_60s"
|
| 19 |
+
music_extractor = AutoFeatureExtractor.from_pretrained("MIT/ast-finetuned-audioset-10-10-0.4593")
|
| 20 |
music_model = AutoModelForAudioClassification.from_pretrained(music_model_id)
|
| 21 |
|
| 22 |
voice_model_id = "superb/hubert-large-superb-sid"
|