44 lines
1.3 KiB
Python
44 lines
1.3 KiB
Python
import os
|
|
import sys
|
|
import subprocess
|
|
import time
|
|
|
|
def run_full_pipeline(audio_file):
|
|
"""
|
|
Lance le pipeline complet : Transcription -> Synthèse.
|
|
"""
|
|
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__))
|
|
|
|
# 1. Transcription
|
|
print("
|
|
[STEP 1] TRANSCRIPTION (Whisper Large v3)...")
|
|
transcribe_cmd = [sys.executable, os.path.join(script_dir, "medical_transcriber.py"), audio_file]
|
|
subprocess.run(transcribe_cmd, check=True)
|
|
|
|
transcript_file = audio_file.rsplit('.', 1)[0] + "_transcript.txt"
|
|
if not os.path.exists(transcript_file):
|
|
print("Erreur : La transcription a échoué.")
|
|
return
|
|
|
|
# 2. Synthèse
|
|
print("
|
|
[STEP 2] SYNTHÈSE MÉDICALE (Ollama/OpenAI)...")
|
|
summarize_cmd = [sys.executable, os.path.join(script_dir, "medical_summarizer.py"), transcript_file]
|
|
subprocess.run(summarize_cmd, check=True)
|
|
|
|
summary_file = audio_file.rsplit('.', 1)[0] + "_summary.md"
|
|
print(f"
|
|
[DONE] Pipeline terminé avec succès !")
|
|
print(f"Transcript : {transcript_file}")
|
|
print(f"Synthèse : {summary_file}")
|
|
|
|
if __name__ == "__main__":
|
|
if len(sys.argv) < 2:
|
|
print("Usage: python run_pipeline.py <audio_file.wav>")
|
|
else:
|
|
run_full_pipeline(sys.argv[1])
|