A Python tool to synchronize an audio file with the textual content of a PDF, line by line, page by page.
This project analyzes an audio file (e.g., .m4a
, .mp3
), automatically transcribes it, and aligns it with the corresponding text from a PDF document.
It’s ideal for audiobooks, learning tools, or accessibility use cases.
- Automatic audio ↔ PDF text alignment
- Audio transcription using Vosk
- Structural PDF analysis (pages, lines, coordinates)
- Visual line highlighting with Tkinter
- Temporary file cleanup
- FastAPI-powered backend
git clone https://github.com/your-username/Pdf-Audio-Synchronizer.git
cd Pdf-Audio-Synchronizer
pip install -r requirements.txt
This project uses the French Vosk model vosk-model-fr-0.22
.
➡️ Download here: vosk-model-fr-0.22
Unzip and place it inside audio_analyser/
:
audio_analyser/
└── vosk-model-fr-0.22/
uvicorn main:app --reload
Test interface: http://localhost:8000/docs
curl -X 'POST' \
'http://localhost:8000/sync?start_page=89&end_page=90' \
-F 'pdf=@data/pdf/example.pdf' \
-F 'audio=@data/audios/example.m4a'
Response:
{
"aligned_data": [
{
"text": "text excerpt",
"page_num": 89,
"pdf_coords": [x0, y0, x1, y1],
"audio_start": 1.23,
"audio_end": 3.45
}
]
}
Run the Tkinter-based demo:
python demo_local.py
Sample files are included in data/
.
- Python 3.13
- FastAPI
- PyMuPDF (fitz)
- ffmpeg
- vosk
- Tkinter
- Pillow
.srt
subtitle export- Web-based visual interface
- Collaborative annotation
- MongoDB or PostgreSQL storage
Un outil Python permettant de synchroniser un enregistrement audio avec le contenu textuel d’un fichier PDF, page par page, ligne par ligne.
Ce projet est conçu pour analyser un fichier audio (au format .m4a
, .mp3
, etc.), le transcrire automatiquement, et l’aligner dynamiquement avec un fichier PDF contenant le texte correspondant.
L’objectif : obtenir une correspondance précise entre le texte lu et le moment où il est lu. C’est utile pour les livres audio, les contenus pédagogiques ou l’accessibilité.
- Synchronisation automatique audio ↔ texte PDF
- Transcription audio via Vosk
- Analyse structurelle des PDF (pages, lignes, coordonnées)
- Visualisation de la synchronisation (Tkinter)
- Nettoyage automatique des fichiers temporaires
- API FastAPI pour usage web
git clone https://github.com/ton-pseudo/Pdf-Audio-Synchronizer.git
cd Pdf-Audio-Synchronizer
pip install -r requirements.txt
Le projet utilise le modèle de reconnaissance vocale français vosk-model-fr-0.22
.
➡️ Téléchargez-le ici : vosk-model-fr-0.22
Décompressez-le et placez le dossier dans audio_analyser/
.
audio_analyser/
└── vosk-model-fr-0.22/
uvicorn main:app --reload
Interface de test disponible sur http://localhost:8000/docs
curl -X 'POST' \
'http://localhost:8000/sync?start_page=89&end_page=90' \
-F 'pdf=@data/pdf/exemple.pdf' \
-F 'audio=@data/audios/exemple.m4a'
Réponse :
{
"aligned_data": [
{
"text": "extrait de texte",
"page_num": 89,
"pdf_coords": [x0, y0, x1, y1],
"audio_start": 1.23,
"audio_end": 3.45
}
]
}
Lancer la visualisation synchronisée avec Tkinter :
python demo_local.py
Des fichiers audio/PDF d’exemple sont fournis dans data/
.
- Python 3.13
- FastAPI
- PyMuPDF (fitz)
- ffmpeg
- vosk
- Tkinter
- Pillow
- Export
.srt
pour sous-titres - Interface web interactive
- Annotation collaborative
- Indexation MongoDB ou PostgreSQL