high quality multi-lingual speech to text
Project description
Verbatim
For high quality multi-lingual speech to text.
Installation
Install from PyPI:
pip install verbatim
Install the latest from git:
pip install git+https://github.com/gaspardpetit/verbatim.git
Usage (from terminal)
Simple usage
verbatim audio_file.mp3
Verbose
verbatim audio_file.mp3 -v
Very Verbose
verbatim audio_file.mp3 -vv
Force CPU only
verbatim audio_file.mp3 --cpu
Save file in a specific directory
verbatim audio_file.mp3 -o ./output/
Usage (from python)
>>> from verbatim import Context, Pipeline
Objectives
High Quality
Many design decisions favour higher confidence over performance, including multiple passes in several parts to improve analysis.
Language support
Languages supported by openai/whisper using the whisper-large-v3 model should also work, including: Afrikaans, Arabic, Armenian, Azerbaijani, Belarusian, Bosnian, Bulgarian, Catalan, Chinese, Croatian, Czech, Danish, Dutch, English, Estonian, Finnish, French, Galician, German, Greek, Hebrew, Hindi, Hungarian, Icelandic, Indonesian, Italian, Japanese, Kannada, Kazakh, Korean, Latvian, Lithuanian, Macedonian, Malay, Marathi, Maori, Nepali, Norwegian, Persian, Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovenian, Spanish, Swahili, Swedish, Tagalog, Tamil, Thai, Turkish, Ukrainian, Urdu, Vietnamese, and Welsh
Mixed language support
Speeches may comprise multiple languages. This includes different languages spoken one after the other (ex. two speakers alternating two languages) or multiple languages being mixed, such as the use of English expressions within a French speech.
Speaker Identification
The speech recognition distinguishes between speakers using diarization based on pyannote.
Word-Level Confidence
The output provides word-level confidence, with poorly recognized words clearly identified to guide manual editing.
Time Tracking
The output text is associated with timestamps to facilitate source audio navigation when manually editing.
Voice Isolation
Verbatim will work on unclean audio sources, for example where there might be music, key strokes from keyboards, background noise, etc. Voices are isolated from other sounds using adefossez/demucs.
For audit purposes, the audio that was removed because it was considered background noise is saved so it can be manually reviewed if necessary.
Optional GPU Acceleration (on a 12GB VRAM Budget)
The current objective is to limit the VRAM requirements to 12GB, allowing cards such as NVidia RTX 4070 to accelerate the processing.
Verbatim will run on CPU, but processing should be expected to be slow.
Long Audio Support (2h+)
The main use case for Verbatim is transcription of meeting. Consequently, it is designed to work with files containing at least 2 hours of audio.
Audio Conversion
A variety of audio formats is support as input, including raw, compressed audio or even video files containing audio tracks. Any format supported by ffmpeg is accepted.
Offline processing
100% offline to ensure confidentiality. The docker image may be executed with --network none
to ensure that nothing reaches out.
Output designed for auditing
The output includes
- a subtitle track rendered over the original audio to review the results.
- a Word document identifying low-confidence words, speaker and timestamps to quickly jump to relevant sections and ensure no part has been omitted
Processing Pipeline
1. Injestion 🔊
Audio Files are converted ◌⃯ to raw audio using ffmpeg.
2. Voice Isolation 🗩
The voices are isolated using karaokenerds/python-audio-separator.
3. Diarization 🖹
Speakers are identified using pyannote. A diarizaton timeline is created with each speaker being assigned speech periods. When known, it is possible to set the number of speaker in advance for better results.
4. Language detection
The language used in each section of the diarization is identified using SYSTRAN/faster-whisper. For sections that fail to detect properly, the process is repeated with widening windows until the language can be determined with an acceptable level of certainty.
5. Speech to Text ✎
We use SYSTRAN/faster-whisper for translation, using the whisper-large-v3 model which support mixture of language. It is still necessary to segment the audio, otherwise whisper eventually switches to translating instead of transcribing when the language requested does not match the speech.
Whisper provides state of the art transcription, but it is prone to hallucinations. A short audio segment may generate speech that does not exist with high level of certainty, making hallucinations difficult to detect. To reduce the likelihood of these occuranges, the audio track is split into multiple audio tracks, one for each speaker
xlanguage
pair. Voice activity detection (VAD) is then performed using speechbrain to identify large audio segments that can be processed together without compromising word timestamp quality.
We use a different VAD for speaker diarization than speech-to-text processing. pyannote's VAD seemed more granular and better suited to identify short segments that may involve change in language or speaker, while speechbrain's VAD seems more conservative, preferring larger segments, making it better suited for grouping large audio segments for speech-to-text while still allowing to skip large sections of silence.
6. Output
The output document is a Microsoft Word document which reflects many decisions of the pipeline. In particular, words with low confidence are highlighted for review. SubStation Alpha Subtitles are also provided, based on the implementation of jianfch/stable-ts.
Sample
Consider the following audio file obtained from universal-soundbank including a mixture of French and English:
https://github.com/gaspardpetit/verbatim/assets/9883156/23bc86d2-567e-4be3-8d79-ba625be8c614
First, we extract the background audio and remove it from the analysis:
Background noise:
https://github.com/gaspardpetit/verbatim/assets/9883156/42fad911-3c15-45c2-a40a-7f923fdd4533
Then we perform diarization and language detection. We correctly detect one speaker speaking in French and another one speaking in English:
Speaker 0 | English:
https://github.com/gaspardpetit/verbatim/assets/9883156/cecec5aa-cb09-473e-bf9b-c5fd82352dab
Speaker 1 | French:
https://github.com/gaspardpetit/verbatim/assets/9883156/8074c064-f4d2-4ec4-8fc0-c985f7c276e8
The output consists of a word document highlighting words with low certainty (low certainty are underlined and highlighted in yello, while medium certainty are simply underlined):
A subtitle file is also provided and can be attached to the original audio:
https://github.com/gaspardpetit/verbatim/assets/9883156/9bcc2553-f183-4def-a9c4-bb0c337d4c82
A direct use of whisper on an audio clip like this one results in many errors. Several utterances end up being translated instead of being transcribed, and others are simply unrecognized and missing:
Naive Whisper Transcription | Verbatim Transcription |
Madame, Monsieur, bonjour et bienvenue à bord. | Madame, Monsieur, bonjour et bienvenue à bord. |
Bienvenue à bord, Mesdames et Messieurs. | Welcome aboard, ladies and gentlemen. |
Pour votre sécurité et votre confort, prenez un moment pour regarder la vidéo de sécurité suivante. | For your safety and comfort, please take a moment to watch the following safety video. |
Ce film concerne votre sécurité à bord. Merci de nous accorder votre attention. | Ce film concerne votre sécurité à bord. Merci de nous accorder votre attention. |
Chaque fois que ce signal est allumé, vous devez attacher votre ceinture pour votre sécurité. | Chaque fois que ce signal est allumé, vous devez attacher votre ceinture pour votre sécurité. |
Nous vous recommandons de la maintenir attachée de façon visible lorsque vous êtes à votre siège. | Nous vous recommandons de la maintenir attachée, de façon visible, lorsque vous êtes à votre siège. |
Lorsque le signe de la selle est en place, votre selle doit être assise en sécurité. Pour votre sécurité, nous recommandons que vous gardiez votre selle assise et visible à tous les temps en selle. | Whenever the seatbelt sign is on, your seatbelt must be securely fastened. For your safety, we recommend that you keep your seatbelt fastened and visible at all times while seated. |
Pour détacher votre selleure, soulevez la partie supérieure de la boucle. | To release the seatbelt, just lift the buckle. |
Il est strictement interdit de fumer dans l'avion, y compris dans les toilettes. | Pour détacher votre ceinture, soulevez la partie supérieure de la boucle. |
Il est strictement interdit de fumer dans l'avion, y compris dans les toilettes. | |
This is a no-smoking flight, and it is strictly prohibited to smoke in the toilets. | |
En cas de dépressurisation, un masque à oxygène tombera automatiquement à votre portée. | En cas de dépressurisation, un masque à oxygène tombera automatiquement à votre portée. |
If there is a sudden decrease in cabin pressure, your oxygen mask will drop automatically in front of you. | |
Tirez sur le masque pour libérer l'oxygène, placez-le sur votre visage. | Tirer sur le masque pour libérer l'oxygène, placez-le sur votre visage. |
Pull the mask toward you to start the flow of oxygen. Place the mask over your nose and mouth. Make sure your own mask is well adjusted before helping others. | |
Une fois votre masque ajusté, il vous sera possible d'aider d'autres personnes. En cas d'évacuation, des panneaux lumineux EXIT vous permettent de localiser les issues de secours. Repérez maintenant le panneau EXIT le plus proche de votre siège. Il peut se trouver derrière vous. | Une fois votre masque ajusté, il vous sera possible d'aider d'autres personnes. En cas d'évacuation, des panneaux lumineux EXIT vous permettent de localiser les issues de secours. Repérez maintenant le panneau EXIT le plus proche de votre siège. Il peut se trouver derrière vous. |
En cas d'urgence, les signes d'exit illuminés vous aideront à locater les portes d'exit. | In case of an emergency, the illuminated exit signs will help you locate the exit doors. |
S'il vous plaît, prenez un moment pour locater l'exit le plus proche de vous. L'exit le plus proche peut être derrière vous. | Please take a moment now to locate the exit nearest you. The nearest exit may be behind you. |
Les issues de secours sont situées de chaque côté de la cabine, à l'avant, au centre, à l'arrière. à l'avant, au centre, à l'arrière. | Les issues de secours sont situées de chaque côté de la cabine, à l'avant, au centre, à l'arrière. |
Emergency exits on each side of the cabin are located at the front, in the center, and at the rear. | |
Pour évacuer l'avion, suivez le marquage lumineux. | Pour évacuer l'avion, suivez le marquage lumineux. |
In the event of an evacuation, pathway lighting on the floor will guide you to the exits. | |
Les portes seront ouvertes par l'équipage. | Les portes seront ouvertes par l'équipage. |
Doors will be opened by the cabin crew. | |
Les toboggans se déploient automatiquement. | Les toboggans se déploient automatiquement. |
The emergency slides will automatically inflate. | |
Le gilet de sauvetage est situé sous votre siège ou dans la coudoir centrale. | Le gilet de sauvetage est situé sous votre siège ou dans la coudoir centrale. |
Your life jacket is under your seat or in the central armrest. | |
Passez la tête dans l'encolure, attachez et serrez les sangles. | Passez la tête dans l'encolure, attachez et serrez les sangles. |
Place it over your head and pull the straps tightly around your waist. Inflate your life jacket by pulling the red toggles. | |
Une fois à l'extérieur de l'avion, gonflez votre gilet en tirant sur les poignées rouges. | Une fois à l'extérieur de l'avion, gonflez votre gilet en tirant sur les poignées rouges. |
Faites-le seulement quand vous êtes à l'extérieur de l'avion. | Do this only when you are outside the aircraft. |
Nous allons bientôt décoller. La tablette doit être rangée et votre dossier redressé. | Nous allons bientôt décoller. La tablette doit être rangée et votre dossier redressé. |
In preparation for takeoff, please make sure your tray table is stowed and secure and that your seat back is in the upright position. | |
L'usage des appareils électroniques est interite pendant le décollage et l'atterrissage. | L'usage des appareils électroniques est interdit pendant le décollage et l'atterrissage. |
The use of electronic devices is prohibited during takeoff and landing. | |
Les téléphones portables doivent rester éteints pendant tout le vol. | Les téléphones portables doivent rester éteints pendant tout le vol. |
Mobile phones must remain switched off for the duration of the flight. | |
Une notice de sécurité placée devant vous est à votre disposition. | Une notice de sécurité placée devant vous est à votre disposition. |
Merci encourage everyone to read the safety information leaflet located in the seat back pocket. | We encourage everyone to read the safety information leaflet located in the seat back pocket. |
Merci pour votre attention. Nous vous souhaitons un bon vol. | Merci pour votre attention. Nous vous souhaitons un bon vol. |
Thank you for your attention. We wish you a very pleasant flight. | Thank you for your attention. We wish you a very pleasant flight. |
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file verbatim-0.1.0.tar.gz
.
File metadata
- Download URL: verbatim-0.1.0.tar.gz
- Upload date:
- Size: 40.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92af8089418d3816160cb389f23ba73058f7a394fa3e0ea56b95ea4b7f1492cc |
|
MD5 | e185f3bb1570b8a1ac748c1de8c96d03 |
|
BLAKE2b-256 | 5613fc93385da096513b2fce0fe2c6ec24cb2411f935553471ab38830349575e |
File details
Details for the file verbatim-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: verbatim-0.1.0-py3-none-any.whl
- Upload date:
- Size: 49.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2818e8618b0e8c8a341cdf5b82785a5a42929d5cdb134fba829670a65f71b9de |
|
MD5 | dd39e08c5b354282a4b74930069a82a2 |
|
BLAKE2b-256 | f3d18b5b805da8dd4ba77f2a4fd10e471a92695d76ebc18cb4b87ddf92512e1f |