Initial commit
This commit is contained in:
53
full_auto_medical_scribe.py
Normal file
53
full_auto_medical_scribe.py
Normal file
@@ -0,0 +1,53 @@
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
def run_full_auto(audio_file, hf_token):
|
||||
"""
|
||||
Pipeline complet : Diarisation + Transcription -> Synthèse Médicale.
|
||||
"""
|
||||
if not os.path.exists(audio_file):
|
||||
print(f"Erreur : Le fichier {audio_file} n'existe pas.")
|
||||
return
|
||||
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
# Étape 1 : Diarisation et Transcription (Pyannote + Whisper)
|
||||
print("
|
||||
[STEP 1/2] DIARISATION & TRANSCRIPTION (Top Qualité)...")
|
||||
env = os.environ.copy()
|
||||
env["HF_TOKEN"] = hf_token
|
||||
|
||||
diarizer_script = os.path.join(script_dir, "medical_diarizer.py")
|
||||
subprocess.run([sys.executable, diarizer_script, audio_file], env=env, check=True)
|
||||
|
||||
# Le fichier de sortie attendu du diarizer
|
||||
transcript_file = audio_file.rsplit('.', 1)[0] + "_diarized.txt"
|
||||
|
||||
if not os.path.exists(transcript_file):
|
||||
print("Erreur : La transcription avec diarisation a échoué.")
|
||||
return
|
||||
|
||||
# Étape 2 : Synthèse IA (Ollama ou OpenAI)
|
||||
print("
|
||||
[STEP 2/2] GÉNÉRATION DE LA SYNTHÈSE MÉDICALE...")
|
||||
summarizer_script = os.path.join(script_dir, "medical_summarizer.py")
|
||||
subprocess.run([sys.executable, summarizer_script, transcript_file], check=True)
|
||||
|
||||
summary_file = audio_file.rsplit('.', 1)[0] + "_diarized_summary.md"
|
||||
|
||||
print("
|
||||
" + "="*50)
|
||||
print("PIPELINE MÉDICAL TERMINÉ AVEC SUCCÈS")
|
||||
print(f"Transcription structurée : {transcript_file}")
|
||||
print(f"Synthèse médicale finale : {summary_file}")
|
||||
print("="*50)
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 2:
|
||||
print("Usage: python full_auto_medical_scribe.py <votre_audio.wav>")
|
||||
else:
|
||||
# On utilise le token que vous m'avez fourni
|
||||
TOKEN = "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"
|
||||
run_full_auto(sys.argv[1], TOKEN)
|
||||
Reference in New Issue
Block a user