Add model auto-download and English logging
This commit is contained in:
+6
-6
@@ -27,7 +27,7 @@ def load_audio(file_path: str, sr: int = 16000) -> Tuple[np.ndarray, int]:
|
||||
try:
|
||||
with wave.open(file_path, 'rb') as wav_file:
|
||||
if wav_file.getnchannels() != 1:
|
||||
logger.warning("Файл %s не моно-аудио", file_path)
|
||||
logger.warning("File %s is not mono audio", file_path)
|
||||
|
||||
frames = wav_file.readframes(-1)
|
||||
audio_array = np.frombuffer(frames, dtype=np.int16).astype(np.float32) / 32768.0
|
||||
@@ -41,7 +41,7 @@ def load_audio(file_path: str, sr: int = 16000) -> Tuple[np.ndarray, int]:
|
||||
return audio_array, sampling_rate
|
||||
|
||||
except Exception as e:
|
||||
logger.error("Ошибка при загрузке аудио %s: %s", file_path, e)
|
||||
logger.error("Failed to load audio %s: %s", file_path, e)
|
||||
raise
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ def get_audio_duration(file_path: str) -> float:
|
||||
Длительность в секундах.
|
||||
"""
|
||||
if not os.path.exists(file_path):
|
||||
raise Exception(f"Файл не существует: {file_path}")
|
||||
raise Exception(f"File does not exist: {file_path}")
|
||||
|
||||
cmd = [
|
||||
"ffprobe",
|
||||
@@ -70,8 +70,8 @@ def get_audio_duration(file_path: str) -> float:
|
||||
result = subprocess.run(cmd, capture_output=True, text=True, check=True, timeout=10)
|
||||
return float(result.stdout.strip())
|
||||
except subprocess.TimeoutExpired:
|
||||
raise Exception(f"Таймаут при определении длительности файла {file_path}")
|
||||
raise Exception(f"Timed out while determining duration for file {file_path}")
|
||||
except subprocess.CalledProcessError as e:
|
||||
raise Exception(f"Ошибка ffprobe для файла {file_path}: {e.stderr}")
|
||||
raise Exception(f"ffprobe error for file {file_path}: {e.stderr}")
|
||||
except (ValueError, TypeError) as e:
|
||||
raise Exception(f"Ошибка при преобразовании длительности для файла {file_path}: {e}")
|
||||
raise Exception(f"Failed to parse duration for file {file_path}: {e}")
|
||||
|
||||
Reference in New Issue
Block a user