Extrait la transcription derriere le contrat Transcripteur
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
"""Choisit le moteur de transcription d'après le matériel."""
|
||||
import platform
|
||||
import sys
|
||||
|
||||
|
||||
def nom_moteur_pour(plateforme, machine, cuda_disponible):
|
||||
"""Décide du moteur. Fonction PURE : aucune interrogation de la machine ici,
|
||||
ce qui rend les quatre configurations testables depuis un seul poste."""
|
||||
if plateforme.startswith("darwin") and machine in ("arm64", "aarch64"):
|
||||
return "mlx"
|
||||
return "faster-gpu" if cuda_disponible else "faster-cpu"
|
||||
|
||||
|
||||
def detecter_moteur():
|
||||
"""Interroge la machine, puis délègue la décision à `nom_moteur_pour`."""
|
||||
return nom_moteur_pour(sys.platform, platform.machine(), _cuda_disponible())
|
||||
|
||||
|
||||
def _cuda_disponible():
|
||||
try:
|
||||
import ctypes
|
||||
ctypes.CDLL("libcudart.so")
|
||||
return True
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
|
||||
def choisir_transcripteur(nom, modele, langue, amorce):
|
||||
"""Rend l'implémentation du contrat Transcripteur portant ce nom."""
|
||||
if nom == "mlx":
|
||||
from moteur.mlx import TranscripteurMLX
|
||||
return TranscripteurMLX(modele, langue, amorce)
|
||||
raise NotImplementedError(f"Moteur non pris en charge à cette étape : {nom}")
|
||||
Reference in New Issue
Block a user