👍️[Update] All : 不要なprintLogを削除 / なるべくtry exceptした場合にはerrorLogを保存するように変更

This commit is contained in:
misyaguziya
2024-12-16 23:38:05 +09:00
parent 030b8a9f01
commit 3fa819df3f
14 changed files with 73 additions and 67 deletions

View File

@@ -3,6 +3,7 @@ from io import BytesIO
from threading import Event
import wave
from speech_recognition import Recognizer, AudioData, AudioFile
from speech_recognition.exceptions import UnknownValueError
from datetime import timedelta
from pyaudiowpatch import get_sample_size, paInt16
from .transcription_languages import transcription_lang
@@ -11,6 +12,8 @@ from .transcription_whisper import getWhisperModel, checkWhisperWeight
import torch
import numpy as np
from pydub import AudioSegment
from utils import errorLogging
import warnings
warnings.simplefilter('ignore', RuntimeWarning)
@@ -74,9 +77,10 @@ class AudioTranscriber:
if s.avg_logprob < avg_logprob or s.no_speech_prob > no_speech_prob:
continue
text += s.text
except Exception:
except UnknownValueError:
pass
except Exception:
errorLogging()
finally:
pass

View File

@@ -4,7 +4,6 @@ from typing import Callable
import huggingface_hub
from faster_whisper import WhisperModel
import logging
from utils import printLog
logger = logging.getLogger('faster_whisper')
logger.setLevel(logging.CRITICAL)
@@ -40,10 +39,8 @@ def downloadFile(url, path, func=None):
if isinstance(func, Callable):
total_chunk += len(chunk)
func(total_chunk/file_size)
printLog(f"Downloading Whisper Model: {total_chunk/file_size:.0%}")
except Exception as e:
printLog("warning:downloadFile()", e)
except Exception:
pass
def checkWhisperWeight(root, weight_type):
path = os_path.join(root, "weights", "whisper", weight_type)