Spaces:
Sleeping
Sleeping
fixes api answer
Browse files- __pycache__/app.cpython-311.pyc +0 -0
- app.py +3 -7
- whisper_cache/tiny.pt +3 -0
__pycache__/app.cpython-311.pyc
CHANGED
|
Binary files a/__pycache__/app.cpython-311.pyc and b/__pycache__/app.cpython-311.pyc differ
|
|
|
app.py
CHANGED
|
@@ -31,7 +31,7 @@ app.add_middleware(
|
|
| 31 |
CORSMiddleware,
|
| 32 |
allow_origins=["*"],
|
| 33 |
allow_credentials=True,
|
| 34 |
-
allow_methods=["
|
| 35 |
allow_headers=["*"],
|
| 36 |
)
|
| 37 |
|
|
@@ -92,7 +92,7 @@ log_file_path = os.path.join("/tmp", "server.log")
|
|
| 92 |
logging.basicConfig(
|
| 93 |
level=logging.INFO,
|
| 94 |
format="%(asctime)s - %(levelname)s - %(message)s",
|
| 95 |
-
handlers=[logging.StreamHandler()]
|
| 96 |
)
|
| 97 |
|
| 98 |
|
|
@@ -125,7 +125,6 @@ async def process_audio(
|
|
| 125 |
if not audio_data.any() or sample_rate == 0:
|
| 126 |
raise ValueError("Empty or invalid audio data.")
|
| 127 |
|
| 128 |
-
# Извлекаем признаки из аудиоданных
|
| 129 |
features = extract_features(audio_data, sample_rate)
|
| 130 |
logging.info(f"Features extracted: shape = {features.shape}")
|
| 131 |
|
|
@@ -147,7 +146,6 @@ async def process_audio(
|
|
| 147 |
lev_distance = Levenshtein.distance(transcribed_text_clean, phrase.lower().strip())
|
| 148 |
phrase_length = max(len(transcribed_text_clean), len(phrase))
|
| 149 |
|
| 150 |
-
# Допускаем различие в 40% длины исходной фразы
|
| 151 |
max_acceptable_distance = 0.5 * phrase_length
|
| 152 |
match_phrase = lev_distance <= max_acceptable_distance
|
| 153 |
|
|
@@ -155,9 +153,7 @@ async def process_audio(
|
|
| 155 |
|
| 156 |
return {
|
| 157 |
"prediction": prediction.tolist(),
|
| 158 |
-
"match_phrase": match_phrase
|
| 159 |
-
"lev_distance": lev_distance,
|
| 160 |
-
"transcribed_text": transcribed_text_clean
|
| 161 |
}
|
| 162 |
|
| 163 |
except Exception as e:
|
|
|
|
| 31 |
CORSMiddleware,
|
| 32 |
allow_origins=["*"],
|
| 33 |
allow_credentials=True,
|
| 34 |
+
allow_methods=["GET, POST"],
|
| 35 |
allow_headers=["*"],
|
| 36 |
)
|
| 37 |
|
|
|
|
| 92 |
logging.basicConfig(
|
| 93 |
level=logging.INFO,
|
| 94 |
format="%(asctime)s - %(levelname)s - %(message)s",
|
| 95 |
+
handlers=[logging.StreamHandler()]
|
| 96 |
)
|
| 97 |
|
| 98 |
|
|
|
|
| 125 |
if not audio_data.any() or sample_rate == 0:
|
| 126 |
raise ValueError("Empty or invalid audio data.")
|
| 127 |
|
|
|
|
| 128 |
features = extract_features(audio_data, sample_rate)
|
| 129 |
logging.info(f"Features extracted: shape = {features.shape}")
|
| 130 |
|
|
|
|
| 146 |
lev_distance = Levenshtein.distance(transcribed_text_clean, phrase.lower().strip())
|
| 147 |
phrase_length = max(len(transcribed_text_clean), len(phrase))
|
| 148 |
|
|
|
|
| 149 |
max_acceptable_distance = 0.5 * phrase_length
|
| 150 |
match_phrase = lev_distance <= max_acceptable_distance
|
| 151 |
|
|
|
|
| 153 |
|
| 154 |
return {
|
| 155 |
"prediction": prediction.tolist(),
|
| 156 |
+
"match_phrase": match_phrase
|
|
|
|
|
|
|
| 157 |
}
|
| 158 |
|
| 159 |
except Exception as e:
|
whisper_cache/tiny.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:65147644a518d12f04e32d6f3b26facc3f8dd46e5390956a9424a650c0ce22b9
|
| 3 |
+
size 75572083
|