Skip to main content

Malayalam phonetic analyser

Project description

PyPI Version

This is python interface for the Malayalam phonetic analyser - mlphon.

Installation

Python 3 is required. Using with venv is recommended

$ pip install mlphon

Usage

Grapheme to Phoneme analysis example

from mlphon import G2P
analyser = G2P()
analyser.analyse('കേരളം')

Gives

[(('<BoS>k<plosive><voiceless><unaspirated><velar>eː<v_sign><EoS><BoS>ɾ<flapped><alveolar>a<schwa><EoS><BoS>ɭ<lateral><retroflex>a<schwa>m<anuswara><EoS>', 0.0),))]

The second item in this result is the weight. It is not relevant in the current implementation.

Grapheme to Phoneme generation example

from mlphon import G2P
generator = G2P()
generator.generate('<BoS>k<plosive><voiceless><unaspirated><velar>eː<v_sign><EoS><BoS>ɾ<flapped><alveolar>a<schwa><EoS><BoS>ɭ<lateral><retroflex>a<schwa>m<anuswara><EoS>')

Gives

(('കേരളം', 0.0),)

The second item in this result is the weight. It is not relevant in the current implementation.

Grapheme to IPA analysis

from mlphon import IPA
analyser = IPA()
analyser.analyse("കേരളം")

Gives

(('keːɾaɭam<anuswara>', 0.0),)

<anauswara>, <visarga>, <chillu> tags are explicitly shown in the IPA analysis.

Grapheme generation from IPA

from mlphon import IPA
generator = IPA()
generator.generate('keːɾaɭam<anuswara>')

Gives

(('കേരളം', 0.0),)

There can be multiple results in this generation. Please ignore the irrelevant ones, if any.

Syllablizer

from mlphon import Syllablizer
syl = Syllablizer()
syl.syllablize('കേരളം')

Gives

['കേ', 'ര', 'ളം']

Command line interface

G2P

$ mlg2p --help
  usage: mlg2p [-h] [-i INFILE] [-o OUTFILE] [-a] [-g] [-v]
  optional arguments:
  -h, --help            show this help message and exit
  -i INFILE, --input INFILE
                    source of analysis data
  -o OUTFILE, --output OUTFILE
                    target of generated strings
  -a, --analyse         Analyse the input file strings
  -g, --generate        Generate the input file strings
  -v, --verbose         print verbosely while processing

IPA

$ mlipa --help
  usage: mlipa [-h] [-i INFILE] [-o OUTFILE] [-a] [-g] [-v]
  optional arguments:
  -h, --help            show this help message and exit
  -i INFILE, --input INFILE
                    source of analysis data
  -o OUTFILE, --output OUTFILE
                    target of generated strings
  -a, --analyse         Analyse the input file strings
  -g, --generate        Generate the input file strings
  -v, --verbose         print verbosely while processing

Syllablizer

$ mlsyllablize --help
  usage: mlsyllablize [-h] [-i INFILE] [-o OUTFILE]
  optional arguments:
  -h, --help            show this help message and exit
  -i INFILE, --input INFILE
                    source of analysis data
  -o OUTFILE, --output OUTFILE
                    target of generated strings

Tag Parse Functions

The analysis function of G2P returns the output with tags in angle brackets.The following functions parses and separates tags, syllables and phoneme sequences.

getPhonemelist()

from mlphon import G2P, getPhonemelist
g2p = G2P()
analysis = g2p.analyse('കേരളം')
for item in analysis:
  getPhonemelist(item[0])

Gives

'k eː ɾ a ɭ a m'

getPhonemetaglist()

from mlphon import G2P, getPhonemetaglist
g2p = G2P()
analysis = g2p.analyse('കേരളം')
for item in analysis:
  getPhonemetaglist(item[0])

Gives

[{'phonemes': [{'ipa': 'k', 'tags': ['plosive', 'voiceless', 'unaspirated', 'velar']}, {'ipa': 'eː', 'tags': ['v_sign']}]}, {'phonemes': [{'ipa': 'ɾ', 'tags': ['flapped', 'alveolar']}, {'ipa': 'a', 'tags': ['schwa']}]}, {'phonemes': [{'ipa': 'ɭ', 'tags': ['lateral', 'retroflex']}, {'ipa': 'a', 'tags': ['schwa']}, {'ipa': 'm', 'tags': ['anuswara']}]}]

getSyllablelist()

from mlphon import G2P, getSyllablelist
g2p = G2P()
analysis = g2p.analyse('കേരളം')
for item in analysis:
  getSyllablelist(item[0])

It gives the syllable separated output as:

['k<plosive><voiceless><unaspirated><velar>eː<v_sign>', 'ɾ<flapped><alveolar>a<schwa>', 'ɭ<lateral><retroflex>a<schwa>m<anuswara>']

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

mlphon-2.0.0.tar.gz (11.0 kB view details)

Uploaded Source

File details

Details for the file mlphon-2.0.0.tar.gz.

File metadata

  • Download URL: mlphon-2.0.0.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for mlphon-2.0.0.tar.gz
Algorithm Hash digest
SHA256 cbaea28a4d83bea3b87560eccfcaaabee75484e48296fb3b889709b415a36419
MD5 7552d4cf1fa6547aff9ff7c92e012242
BLAKE2b-256 fff2cb72aa4daa6ae8e5dc52820a4be8634bd295e1b6b70745a7e9875122991a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page