How it works | Live demo | PyPI
Etalon finds where every word and every letter of a known text begins and ends in a recording of it (forced alignment). It uses no neural model and needs no training and no graphics card: the whole method is a few hundred lines of numpy and a small bank of sounds that ships with the package.
- Serbian and Croatian, measured. Bosnian and Montenegrin work the same way and are not measured yet.
- Between half a minute and two minutes of work on a desktop processor for an hour of sound.
- A recording and its plain text are enough; no times, no subtitles and no cutting are needed.
- Works on one recording, or on a whole dataset read as a stream from Hugging Face.
- From the command line, from Python, or on a page in the browser.
The method is described in Etalon.
Install
pip install cawn-etalon # one recording at a time
pip install "cawn-etalon[hf]" # also whole datasets (adds huggingface_hub and pyarrow)
The command and the Python module are both called etalon.
Python 3.9 or newer. A plain 16 kHz mono .wav is read directly; any other sound needs ffmpeg
on the path.
Use
In the browser
etalon ui
A page opens on this computer (nothing is sent anywhere). Drop a recording, paste its text, and hear the result with the word that sounds lit. The same page lays whole datasets and makes banks for other languages, and shows the log of everything it works on.
Command line
etalon recording.wav text.txt # -> recording.srt, recording.json
etalon recording.mp3 text.txt --format srt,vtt,json,tsv,textgrid,html --out folder/name
etalon recording.wav subtitles.srt # only the text of the subtitles is used
--format html writes a page to hear the result. On it, red words are the tenth of the words
that fit their sound worst and yellow the next 15 %. These marks are relative: a tenth of the
words is always red, in the best result too. They say where to listen first, not that a word is
wrong.
Python
import etalon
result = etalon.align("recording.wav", "text.txt", lang="sr")
for word in result["words"]:
print(word["word"], word["start"], word["end"]) # seconds
etalon.save(result, "name", ("srt", "json"))
Every word also has its letters (letter, start, end), a mark (higher fits better) and a
doubt (0, 1 or 2). result["fit"] and result["match"] say whether the text belongs to the sound.
A whole dataset
Every row a sound and its text. A Hugging Face repository is read as a stream, so nothing is downloaded whole; a folder of parquet files on disk works too.
etalon dataset OWNER/NAME # shows the columns it has
etalon dataset OWNER/NAME --audio_column audio --text_column text --limit 100 --html 20
etalon dataset OWNER/NAME --audio_column audio --text_column text --speaker_column speaker --push OWNER/NEW
The rows are written out as parquet with new columns: words, letters, etalon_slide,
etalon_mark, etalon_ok. --html 20 adds a page to hear the first 20 rows. --push sends the
result to a new repository, which is made private; its licence is yours to set.
Languages
--lang |
language | bank of sounds | measured |
|---|---|---|---|
sr |
Serbian | its own (Serbian parliament) | yes |
hr |
Croatian | the Serbian one | yes |
bs, me |
Bosnian, Montenegrin | the Serbian one | not yet |
| any other code | a language said the way it is written | made by you, once (below) | no |
A bank for another language is made once, from a dataset that already has the times of its
letters (a list of {letter, start, end} per row, from another aligner). After that Etalon lays
that language by itself:
etalon bank OWNER/NAME --lang sl --audio_column audio --letters_column letters --speaker_column speaker
etalon recording.wav text.txt --lang sl
The bank is kept in ~/.etalon/bank_sl.pkl. With --speaker_column it is made in two rounds,
every speaker moved to a standard voice first, as the Serbian one was; without it in one round,
and it is blunter.
Making a bank cannot quietly go wrong:
- The code must be your own.
sr,hr,bsandmecome with Etalon and are refused: a bank made under one of them would never be used. - A bank that is already there is not replaced unless you add
--overwrite; the old one is then kept beside the new one asbank_sl.pkl.bak. - Letter times that do not fit the sound (milliseconds instead of seconds, or counted from the start of the whole recording) stop the work before it has begun.
- When the bank is made it is tried on rows that were kept out of it, and you are told how many letter starts it finds within 50 ms of the dataset's own times. This says whether the bank was made from sound data. It does not say how right the dataset's times are: Etalon can only be as good as the aligner it learned from.
etalon banks # every bank on this computer: what it is for, how it was made, its check, its file
etalon banks remove sl # take a bank you made away (it asks first; --yes does not)
The bank that comes with Etalon cannot be removed or replaced. The same list, with a Remove
button, is on the page etalon ui under "Language bank".
Numbers written in digits are read out: by Etalon's own tables for the four languages above, by
the package num2words for the others it knows. Where neither can, write the numbers as words.
Languages written one way and said another (English, French) are beyond this method: they would need a dictionary of pronunciations.
Accuracy
The share of word starts that lie within 50 ms of the times of another aligner. Those times are not the truth, only the ruler that exists.
| speech | against | within 50 ms |
|---|---|---|
| Serbian parliament, short pieces | times published with ParlaSpeech-RS | 93.8 % (MFA on the same: 93.9 %) |
| Serbian videos, short pieces, one speaker (14 videos) | Montreal Forced Aligner | 88.5 % |
| Serbian video of 90 minutes, several speakers | Montreal Forced Aligner | 87.3 % |
| Serbian, a whole hour from its plain text | Montreal Forced Aligner | 85.4 % |
| Croatian parliament, one hour, Serbian bank | times published with ParlaSpeech-HR | 81.2 % (97.1 % within 100 ms) |
Settings
Every setting is an argument of the command; three of them can also be set as a variable of the terminal.
| argument | variable | what it does |
|---|---|---|
--lang CODE |
ETALON_LANG |
the language (default sr) |
--slide MODE |
ETALON_SLIDE |
one voice or several. auto (default): Etalon decides. video: one voice, the fastest. piece: always several |
--fit 65 |
ETALON_FIT |
the text must explain at least so many percent of the start of the sound, or a warning is given and the command exits with 2 |
--bank NAME |
which bank of sounds (default auto) |
|
--minutes N |
only the first N minutes of the recording | |
ETALON_DATA |
a folder with other banks |
How it works
- Rows. The sound becomes one row of 26 frequency bands every 10 ms. A slide moves the bands of a speaker towards a standard voice; there are 9 slides.
- Bank. From speech whose letter times are known, the bank keeps the usual row of every half of a letter together with its neighbour.
- Path. The text becomes a chain of letter halves and silences, and the chain is stretched over the rows of the sound so that the sum of the fits is the largest.
- Voices. Pieces spread over the recording each pick the slide that fits them. If they agree it is one voice; if they do not, several people talk and every piece gets its own slide.
Limits
- The text must be what is said. Abbreviations must be written the way they are spoken; numbers in digits are read in their basic form.
- The check "does the text belong to the sound" looks only at the first minute and a half, and works only where the recording is mostly speech. With street noise or music and little speech a wrong text can pass.
- Bosnian, Montenegrin and banks made for other languages are not measured.
- The times of word ends agree with other aligners less than the times of word starts.
Development
pip install -e ".[dev]"
pytest # needs no sound
black . # line length 110
The code lies in folders by what it does:
| folder | modules | what |
|---|---|---|
etalon/ |
config.py, errors.py |
constants and file locations; the one error |
audio/ |
reading.py, features.py |
reading the sound; its rows of 26 bands, the 9 slides |
text/ |
words.py, numbers.py, languages.py |
words to the letters that are said, numbers, languages |
soundbank/ |
model.py, files.py |
what a bank is and how one is made; the bank files: keep, list, remove |
laying/ |
path.py, slide.py, align.py |
a text stretched over its sound; the slide; align and align_all |
output/ |
subtitles.py, pages.py, save.py |
srt, vtt, tsv, TextGrid; pages to hear; writing the files |
dataset/ |
files.py, rows.py, language_bank.py, bank_check.py |
whole datasets; making and checking the bank of a language |
app/ |
cli.py, ui.py, ui.html |
the command line and the page in the browser |
What is meant to be used from outside is on the package itself (etalon.align, etalon.save,
etalon.list_banks ...) and in etalon.dataset (align_dataset, make_language_bank).
Licence
The code is under the Apache License 2.0 (see LICENSE).
The bank of sounds, etalon/data/bank_parliament.pkl, is derived from
ParlaSpeech-RS 4.0 (CLARIN.SI) and is shared under the same
licence, CC BY-SA 4.0.
Metadata
Release files for cawn-etalon 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cawn_etalon-0.1.3.tar.gz | 488.0 kB | Without provenance | Details for cawn_etalon-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cawn_etalon-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for cawn_etalon-0.1.3-py3-none-any.whl |
Total release size: 981.5 kB
Release files / cawn_etalon-0.1.3.tar.gz
| Download URL | cawn_etalon-0.1.3.tar.gz |
|---|---|
| Size | 488.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0077fcbd2e905bb83ae881f65a3eb5a0c8f9cef22c5e3524ae00f799dd052613
|
|
BLAKE2b-256 checksum How to use checksums |
4e99bbb50863c09d8bd3da1acd32d0370df66ce93ecee6d239f16a8c7e3a274e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.12
|
Release files / cawn_etalon-0.1.3-py3-none-any.whl
| Download URL | cawn_etalon-0.1.3-py3-none-any.whl |
|---|---|
| Size | 493.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
57c8d35d08cf9d75312d2d86b3fb17fa5306f99a2b2737b06c4955d126876027
|
|
BLAKE2b-256 checksum How to use checksums |
0e459cedec609e1f40d26f7d6d2668ca5b1f7eb5d5a08f168605803dced692ab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.12
|
Security for cawn-etalon 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.