spoteno
spoteno (Spoken-Text-Normalization) is a tool to cleanup text-transcripts for speech recognition systems. These systems normally expect target transcripts to contain only characters from a restricted set.
Installation
Install the latest development version:
pip install git+https://github.com/ynop/spoteno.git
Examples
The default usecase would be to normalize a sentence. This enforces the output string to contain only valid characters (as defined by the configuration).
import spoteno
sentence = ('Am 11. Januar geht er um 5m nach links,'
'weshalb er $d schon "ziemlich" müde ist.')
norm = spoteno.Normalizer.de()
outsent = norm.normalize(sentence)
print(outsent)
# >>> am elfte januar geht er um fünf m nach links weshalb er d schon ziemlich müde ist
With force=False, the final cleanup can be disabled.
This way invalid characters may occurr in the output,
if the configuration hasn't handled them specifically.
outsent = norm.normalize(sentence, force=False)
print(outsent)
# >>> am elfte januar geht er um fünf m nach links weshalb er $d schon ziemlich müde ist
With the debug method, one can retrieve a set of invalid characters in the final output. This can be used to create or debug a configuration. Additionaly the outputs of the different configuration steps can be printed.
outsent, error = norm.debug(sentence)
print(error)
# >>> START Am 11. Januar geht er um 5m nach links,weshalb er $d schon "ziemlich" müde ist.
# >>> Strip ['Am 11. Januar geht er um 5m nach links,weshalb er $d schon "ziemlich" müde ist.']
# >>> Lower ['am 11. januar geht er um 5m nach links,weshalb er $d schon "ziemlich" müde ist.']
# >>> StripChar ['am 11. januar geht er um 5m nach links,weshalb er $d schon "ziemlich" müde ist']
# >>> ReplaceIfNotSurroundedByDigits['am 11. januar geht er um 5m nach links weshalb er $d schon "ziemlich" müde ist']
# >>> ReplaceIfNotPrecededByDigit['am 11. januar geht er um 5m nach links weshalb er $d schon "ziemlich" müde ist']
# >>> ReplaceRegex ['am 11. januar geht er um 5m nach links weshalb er $d schon "ziemlich" müde ist']
# >>> ReplaceChar ['am 11. januar geht er um 5m nach links weshalb er $d schon ziemlich müde ist']
# >>> ReplaceChar ['am 11. januar geht er um 5m nach links weshalb er $d schon ziemlich müde ist']
# >>> WhitespaceTokenize ['am', '11.', 'januar', 'geht', 'er', 'um', '5m', 'nach', 'links', 'weshalb', 'er', '$d', 'schon', 'ziemlich', 'müde', 'ist']
# >>> SplitNumberSuffix ['am', '11.', 'januar', 'geht', 'er', 'um', '5', 'm', 'nach', 'links', 'weshalb', 'er', '$d', 'schon', 'ziemlich', 'müde', 'ist']
# >>> NumberToWords ['am', '11.', 'januar', 'geht', 'er', 'um', 'fünf', 'm', 'nach', 'links', 'weshalb', 'er', '$d', 'schon', 'ziemlich', 'müde', 'ist']
# >>> OrdinalNumberToWords['am', 'elfte', 'januar', 'geht', 'er', 'um', 'fünf', 'm', 'nach', 'links', 'weshalb', 'er', '$d', 'schon', 'ziemlich', 'müde', 'ist']
# >>> ReplaceChar ['am', 'elfte', 'januar', 'geht', 'er', 'um', 'fünf', 'm', 'nach', 'links', 'weshalb', 'er', '$d', 'schon', 'ziemlich', 'müde', 'ist']
# >>> ReplaceFull ['am', 'elfte', 'januar', 'geht', 'er', 'um', 'fünf', 'm', 'nach', 'links', 'weshalb', 'er', '$d', 'schon', 'ziemlich', 'müde', 'ist']
# >>> RemoveDiacritics ['am', 'elfte', 'januar', 'geht', 'er', 'um', 'fünf', 'm', 'nach', 'links', 'weshalb', 'er', '$d', 'schon', 'ziemlich', 'müde', 'ist']
# >>> Strip ['am', 'elfte', 'januar', 'geht', 'er', 'um', 'fünf', 'm', 'nach', 'links', 'weshalb', 'er', '$d', 'schon', 'ziemlich', 'müde', 'ist']
# >>> END ['am', 'elfte', 'januar', 'geht', 'er', 'um', 'fünf', 'm', 'nach', 'links', 'weshalb', 'er', '$d', 'schon', 'ziemlich', 'müde', 'ist']k
# >>> {'$'}
Development
Prerequisites
It's recommended to use a virtual environment when developing spoteno. To create one, execute the following command in the project's root directory:
python -m venv .
To install spoteno and all it's dependencies, execute:
pip install -e .
Running the test suite
pip install -e .[dev]
python setup.py test
With PyCharm you might have to change the default test runner. Otherwise, it might only suggest to use nose. To do so, go to File > Settings > Tools > Python Integrated Tools (on the Mac it's PyCharm > Preferences > Settings > Tools > Python Integrated Tools) and change the test runner to py.test.
Versions
Versions is handled using bump2version. To bump the version:
bump2version [major,minor,patch,release,num]
In order to directly go to a final relase version (skip .dev/.rc/...):
bump2version [major,minor,patch] --new-version x.x.x
Release
Commands to create a new release on pypi.
rm -rf build
rm -rf dist
python setup.py sdist
python setup.py bdist_wheel
twine upload dist/*
Metadata
Release files for spoteno 0.1.1
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 |
|---|---|---|---|---|
| spoteno-0.1.1.tar.gz | 10.8 kB | Without provenance | Details for spoteno-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| spoteno-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for spoteno-0.1.1-py3-none-any.whl |
Total release size: 22.1 kB
Release files / spoteno-0.1.1.tar.gz
| Download URL | spoteno-0.1.1.tar.gz |
|---|---|
| Size | 10.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e9e384d4a9a596d3386f2e9338075225a31d2c1306b24b99b58716757abd4523
|
|
BLAKE2b-256 checksum How to use checksums |
071cd19634a37580636d1228ea4465e6950ff2a9d9900891f7fdcca70d2908b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.7.4
|
Release files / spoteno-0.1.1-py3-none-any.whl
| Download URL | spoteno-0.1.1-py3-none-any.whl |
|---|---|
| Size | 11.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
56d8eff2fb8bfb2f81adbb7bc85335577ec075f23d5c33f0f2ec503f146ffc1e
|
|
BLAKE2b-256 checksum How to use checksums |
a86aaad25f6b2c7cb43ae3868ae4f90c4b230edab0852585df47a6235df912b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.7.4
|
Security for spoteno 0.1.1
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.