Python Interface for Malayalam phonetic analyser
This is python interface for the Malayalam phonetic analyser - mlphon.
Installation
Requires Python 3.9–3.12. Install using pip or uv:
$ pip install mlphon
or with uv:
$ uv pip install mlphon
Syllablize a Malayalam Word
The following python snippet will split a word in Malayalam script into syllables.
from mlphon import PhoneticAnalyser mlphon = PhoneticAnalyser() mlphon.split_to_syllables('കേരളം')
It will give the result
[‘കേ’, ‘ര’, ‘ളം’]
Phonetically analyse a Malayalam Word
from mlphon import PhoneticAnalyser mlphon = PhoneticAnalyser() mlphon.analyse('കേരളം')
It gives the result as a sequence of ipa and associated phonetic tags.
[{‘phonemes’: [{‘ipa’: ‘k’, ‘tags’: [‘plosive’, ‘voiceless’, ‘unaspirated’, ‘velar’]}, {‘ipa’: ‘eː’, ‘tags’: [‘v_sign’]}]}, {‘phonemes’: [{‘ipa’: ‘ɾ’, ‘tags’: [‘flapped’, ‘alveolar’]}, {‘ipa’: ‘a’, ‘tags’: [‘inherentvowel’]}]}, {‘phonemes’: [{‘ipa’: ‘ɭ’, ‘tags’: [‘lateral’, ‘retroflex’]}, {‘ipa’: ‘a’, ‘tags’: [‘inherentvowel’]}, {‘ipa’: ‘m’, ‘tags’: [‘anuswara’]}]}]
Malayalam g2p : Grapheme to Phoneme conversion
from mlphon import PhoneticAnalyser mlphon = PhoneticAnalyser() mlphon.grapheme_to_phoneme('കാറ്റ്')
It gives the ipa sequence as output.
[‘kaːṯṯə’]
Malayalam p2g : Phoneme to Grapheme conversion
from mlphon import PhoneticAnalyser mlphon = PhoneticAnalyser() mlphon.phoneme_to_grapheme('paːlə')
It gives the corresponding grapheme sequences as output.
[പാല്’]
Command Line Interface for the above operations: mlphon
usage: mlphon [-h] [-s] [-a] [-p] [-pe string] [-se string] [-g] [-i INFILE] [-o OUTFILE] [-v] optional arguments: -h, --help show this help message and exit -s, --syllablize Syllablize the input Malayalam string -a, --analyse Phonetically analyse the input Malayalam string -p, --tophoneme Transcribe the input Malayalam grapheme to phoneme sequence -pe string, --phoneme_end string String to be inserted at end of phoneme -se string, --syllable_end string String to be inserted at end of syllable -g, --tographeme Transcribe the input phoneme sequence to Malayalam grapheme -i INFILE, --input INFILE source of analysis data -o OUTFILE, --output OUTFILE target of generated strings -v, --verbose print verbosely while processing
- For example to perform g2p operation on a set of words stored in input.txt with one Malayalam word per line,
mlphon -p -pe " " -se "." -i path/to/inputfile.txt -o path/to/outputfile.txt- Inputfile contents:
cat path/to/inputfile.txt അകത്തുള്ളത് അകപ്പെട്ടത് അകലെ- Outputfile contents:
അകത്തുള്ളത് a .k a .t̪ t̪ u .ɭ ɭ a .t̪ ə . അകപ്പെട്ടത് a .k a .p p e .ʈ ʈ a .t̪ ə . അകലെ a .k a .l e .
Application: Using mlphon to create a phonetic lexicon
A typical use case of phonetic analysis is to create a phonetic lexicon to be used in Automatic Speech Recognition or Text to Speech Synthesis. The phonetic representation with each phoneme separated by a space can be obtained as below:
from mlphon import PhoneticAnalyser, split_as_phonemes mlphon = PhoneticAnalyser() analysis = mlphon.analyse('എന്നാൽ') for result in analysis: split_as_phonemes(result)
It results in the output, two different valid phoneme sequences:
‘e n̪ n̪ aː l’
‘e n n aː l’
The phonetic representation with each syllable separated by a space can be obtained as below:
from mlphon import PhoneticAnalyser, split_as_syllables mlphon = PhoneticAnalyser() analysis = mlphon.analyse('ഇന്ത്യയുടെ') for result in analysis: split_as_syllables(result)
It results in the output:
‘i n̪t̪ja ju ʈe’
To get phonemes and syllables with user defined end-marker strings as below:
from mlphon import PhoneticAnalyser, phonemize mlphon = PhoneticAnalyser() analysis = mlphon.analyse('ഇന്ത്യയുടെ') for result in analysis: phonemize(result, " ", ".")
It results in the output with a ‘space’ after every phoneme and a ‘period’ after every syllable
‘i .n̪ t̪ j a .j u .ʈ e .’
Metadata
Release files for mlphon 3.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 |
|---|---|---|---|---|
| mlphon-3.1.3.tar.gz | 19.2 kB | Without provenance | Details for mlphon-3.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mlphon-3.1.3-py3-none-any.whl | Python 3 | none | any | Details for mlphon-3.1.3-py3-none-any.whl |
Total release size: 39.0 kB
Release files / mlphon-3.1.3.tar.gz
| Download URL | mlphon-3.1.3.tar.gz |
|---|---|
| Size | 19.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6c73a3f5aabc155dea9ced8e108e027792565683b8e381f092fec8ba6f813fc3
|
|
BLAKE2b-256 checksum How to use checksums |
082898e648abea59d02b257621f2f5314b75d6b084b0e1a0878c678a82e62082
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.8
|
Release files / mlphon-3.1.3-py3-none-any.whl
| Download URL | mlphon-3.1.3-py3-none-any.whl |
|---|---|
| Size | 19.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
067755a1aa1fa3cbb7aa0a7c4d130ceb6df45ee6d19625a3c2296d790acacc94
|
|
BLAKE2b-256 checksum How to use checksums |
d68d81b04a5047b87a696a7a064d499bf996543c6b711c9668c1a0566060270e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.8
|
Security for mlphon 3.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.