mirror of
https://github.com/tcsenpai/whisperapp.git
synced 2025-06-07 07:25:21 +00:00
tried a fix for whisper
This commit is contained in:
parent
3eade21b9f
commit
696cc73e23
31
app.py
31
app.py
@ -28,12 +28,18 @@ config = load_config()
|
|||||||
|
|
||||||
# Whisper configuration
|
# Whisper configuration
|
||||||
DEFAULT_MODEL = config["whisper"]["default_model"]
|
DEFAULT_MODEL = config["whisper"]["default_model"]
|
||||||
DEVICE = config["whisper"]["device"] if torch.cuda.is_available() else "cpu"
|
DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
|
||||||
COMPUTE_TYPE = config["whisper"]["compute_type"] if DEVICE == "cuda" else "float32"
|
COMPUTE_TYPE = "float32" # Always use float32 for better compatibility
|
||||||
BEAM_SIZE = config["whisper"].getint("beam_size")
|
BEAM_SIZE = config["whisper"].getint("beam_size")
|
||||||
VAD_FILTER = config["whisper"].getboolean("vad_filter")
|
VAD_FILTER = config["whisper"].getboolean("vad_filter")
|
||||||
|
|
||||||
logger.info(f"Initialized Whisper with device: {DEVICE}, compute type: {COMPUTE_TYPE}")
|
# Log device and compute type
|
||||||
|
logger.info(f"PyTorch CUDA available: {torch.cuda.is_available()}")
|
||||||
|
if torch.cuda.is_available():
|
||||||
|
logger.info(f"CUDA device: {torch.cuda.get_device_name(0)}")
|
||||||
|
logger.info(f"CUDA version: {torch.version.cuda}")
|
||||||
|
logger.info(f"cuDNN version: {torch.backends.cudnn.version()}")
|
||||||
|
logger.info(f"Using device: {DEVICE}, compute type: {COMPUTE_TYPE}")
|
||||||
logger.info(
|
logger.info(
|
||||||
f"Default model: {DEFAULT_MODEL}, beam size: {BEAM_SIZE}, VAD filter: {VAD_FILTER}"
|
f"Default model: {DEFAULT_MODEL}, beam size: {BEAM_SIZE}, VAD filter: {VAD_FILTER}"
|
||||||
)
|
)
|
||||||
@ -57,8 +63,23 @@ DEFAULT_OLLAMA_MODEL = ollama.get_default_model() if OLLAMA_AVAILABLE else None
|
|||||||
|
|
||||||
def load_model(model_name: str) -> WhisperModel:
|
def load_model(model_name: str) -> WhisperModel:
|
||||||
"""Load the Whisper model with the specified configuration."""
|
"""Load the Whisper model with the specified configuration."""
|
||||||
logger.info(f"Loading Whisper model: {model_name}")
|
try:
|
||||||
return WhisperModel(model_name, device=DEVICE, compute_type=COMPUTE_TYPE)
|
logger.info(f"Loading Whisper model: {model_name}")
|
||||||
|
return WhisperModel(
|
||||||
|
model_name,
|
||||||
|
device=DEVICE,
|
||||||
|
compute_type=COMPUTE_TYPE,
|
||||||
|
download_root=os.path.join(os.path.dirname(__file__), "models"),
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Error loading model with CUDA: {str(e)}")
|
||||||
|
logger.info("Falling back to CPU")
|
||||||
|
return WhisperModel(
|
||||||
|
model_name,
|
||||||
|
device="cpu",
|
||||||
|
compute_type="float32",
|
||||||
|
download_root=os.path.join(os.path.dirname(__file__), "models"),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def transcribe_audio(
|
def transcribe_audio(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user