Skip to content
Related Articles

Related Articles

Convert English text into the Phonetics using Python
  • Last Updated : 11 Oct, 2020
GeeksforGeeks - Summer Carnival Banner

In this article, we are going to see how to convert English text into the International Phonetic Alphabet. We are going to use the eng-to-ipa module to convert into phonetic.

Installation: Run this code into your terminal.

pip install eng-to-ipa 

Let’s understands this module step-by-step:

1. Import this module and use convert() method to convert a string into phonetics.

Syntax: eng_to_ipa.convert(str)



Parameter:

  • str: the text to be converted

Returns: IPA string

Python3




import eng_to_ipa as p
  
  
p.convert("Hello Geeks")

Output:

'hɛˈloʊ giks'

2. Using ipa_list() instead of convert() it returns the list of each word as a list of all its possible transcriptions.

Syntax: eng_to_ipa.ipa_list(str)

Parameter:

  • str: the text to be converted

Return: list of all its possible transcriptions.



Python3




p.ipa_list("Yes i am geeks, How are you")

Output:

[[‘jɛs’], [‘aɪ’], [‘eɪɛm’, ‘æm’], [‘giks,’], [‘haʊ’], [‘ɑr’, ‘ər’], [‘ju’]]

3. The get_rhymes() methods return a list of rhymes for a word or set of words.

Syntax: eng_to_ipa.get_rhymes(str)

Parameter:

  • str: the text to be rhymed

Returns: list of rhymes for a word or set of words.

Python3




p.get_rhymes("Geeks")

Output:

['antiques',
 'batiks',
 'beeks',
 "belgique's",
 'bespeaks',
 'boutiques',
 'cheeks',
 "creek's",
 'creeks',
 'critiques',
 "deak's",
 'eakes',...
 ......
 ..

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :