question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem training for new language.

See original GitHub issue

I am trying to train my model on a Marathi dataset. It is strange espeak doesnt seem to support it although mentioned in their Supported Languages Page.

In [3]: ph = to_phonemes("प्रदर्शनों के दौरान पुलिस की हिंसा और चुनावों में कथित धोखाधड़ी के ख़िलाफ़ बेलारूस में लोगों का गुस्सा बढ़ता ही जा रहा है")
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-3-944424e45249> in <module>
----> 1 ph = to_phonemes("प्रदर्शनों के दौरान पुलिस की हिंसा और चुनावों में कथित धोखाधड़ी के ख़िलाफ़ बेलारूस में लोगों का गुस्सा बढ़ता ही जा रहा है")

<ipython-input-2-a226f9833051> in to_phonemes(text)
      9                          njobs=1,
     10                          punctuation_marks=';:,.!?¡¿—…"«»“”()',
---> 11                          language_switch='remove-flags')
     12     phonemes = phonemes.replace('—', '-')
     13     return phonemes

~/.virtualenvs/forwardtacoenv/lib/python3.6/site-packages/phonemizer/phonemize.py in phonemize(text, language, backend, separator, strip, preserve_punctuation, punctuation_marks, with_stress, language_switch, njobs, logger)
    158             with_stress=with_stress,
    159             language_switch=language_switch,
--> 160             logger=logger)
    161     elif backend == 'espeak-mbrola':
    162         phonemizer = backends[backend](

~/.virtualenvs/forwardtacoenv/lib/python3.6/site-packages/phonemizer/backend/espeak.py in __init__(self, language, punctuation_marks, preserve_punctuation, language_switch, with_stress, logger)
    145         super().__init__(
    146             language, punctuation_marks=punctuation_marks,
--> 147             preserve_punctuation=preserve_punctuation, logger=logger)
    148         self.logger.debug('espeak is %s', self.espeak_path())
    149 

~/.virtualenvs/forwardtacoenv/lib/python3.6/site-packages/phonemizer/backend/base.py in __init__(self, language, punctuation_marks, preserve_punctuation, logger)
     52             raise RuntimeError(
     53                 'language "{}" is not supported by the {} backend'
---> 54                 .format(language, self.name()))
     55         self.language = language
     56 

RuntimeError: language "mr" is not supported by the espeak backend

Now my only solution is to run it directly on grapheme. There is very less difference between the grapheme and phoneme for indic script. So I made the following changes.

cleaners.py

def to_phonemes(text):
    # text = text.replace('-', '—')
    # phonemes = phonemize(text,
    #                      language=hp.language,
    #                      backend='espeak',
    #                      strip=True,
    #                      preserve_punctuation=True,
    #                      with_stress=False,
    #                      njobs=1,
    #                      punctuation_marks=';:,.!?¡¿—…"«»“”()',
    #                      language_switch='remove-flags')
    # phonemes = phonemes.replace('—', '-')
    phonemes = text
    return phonemes

symbols.py

""" from https://github.com/keithito/tacotron """

"""
Defines the set of symbols used in text input to the model.

The default is a set of ASCII characters that works well for English or text that has been run through Unidecode. For other data, you can modify _characters. See TRAINING_DATA.md for details. """
from utils.text import cmudict

_pad = "_"
_punctuation = "!'(),.:;? "
_special = "-"

# Prepend "@" to ARPAbet symbols to ensure uniqueness (some are the same as uppercase letters):
_arpabet = ["@" + s for s in cmudict.valid_symbols]

# Phonemes
# _vowels = 'iyɨʉɯuɪʏʊeøɘəɵɤoɛœɜɞʌɔæɐaɶɑɒᵻ'
# _non_pulmonic_consonants = 'ʘɓǀɗǃʄǂɠǁʛ'
# _pulmonic_consonants = 'pbtdʈɖcɟkɡqɢʔɴŋɲɳnɱmʙrʀⱱɾɽɸβfvθðszʃʒʂʐçʝxɣχʁħʕhɦɬɮʋɹɻjɰlɭʎʟ'
# _suprasegmentals = 'ˈˌːˑ'
# _other_symbols = 'ʍwɥʜʢʡɕʑɺɧ'
# _diacrilics = 'ɚ˞ɫ'

_phones = "ँंःअआइईउऊऋऌऍऎएऐऑऒओऔकखगघङचछजझञटठडढणतथदधनऩपफबभमयरऱलळऴवशषसह़ऽािीुूृॄॅॆेैॉॊोौ्ॐक़ख़ग़ज़ड़ढ़फ़य़ॠ॰ॲ"

phonemes = sorted(
    list(
        _pad
        + _punctuation
        + _special
        + _phones
        # + _non_pulmonic_consonants
        # + _pulmonic_consonants
        # + _suprasegmentals
        # + _other_symbols
        # + _diacrilics
    )
)

When I run python preprocess.py --path /home/ubuntu/datasets/Marathi_trim/ i get this error

/home/ubuntu/.virtualenvs/forwardtacoenv/lib/python3.6/site-packages/librosa/util/decorators.py:9: NumbaDeprecationWarning: An import was requested from a module that has moved location.
Import of 'jit' requested from: 'numba.decorators', please update to use 'numba.core.decorators' or pin to Numba version 0.48.0. This alias will not be present in Numba version 0.50.0.
  from numba.decorators import jit as optional_jit

35999 wav files found in "/home/ubuntu/datasets/Marathi_trim/"

+-------------+-----------+--------+------------+-----------+----------------+
| Sample Rate | Bit Depth | Mu Law | Hop Length | CPU Usage | Num Validation |
+-------------+-----------+--------+------------+-----------+----------------+
|    22050    |     9     |  True  |    256     |  103/104  |      200       |
+-------------+-----------+--------+------------+-----------+----------------+

multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
  File "/usr/lib/python3.6/multiprocessing/pool.py", line 119, in worker
    result = (True, func(*args, **kwds))
  File "preprocess.py", line 56, in process_wav
    m, x = convert_file(path)
  File "preprocess.py", line 42, in convert_file
    peak = np.abs(y).max()
  File "/home/ubuntu/.virtualenvs/forwardtacoenv/lib/python3.6/site-packages/numpy/core/_methods.py", line 39, in _amax
    return umr_maximum(a, axis, None, out, keepdims, initial, where)
ValueError: zero-size array to reduction operation maximum which has no identity
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "preprocess.py", line 91, in <module>
    for i, (item_id, length, cleaned_text) in enumerate(pool.imap_unordered(process_wav, wav_files), 1):
  File "/usr/lib/python3.6/multiprocessing/pool.py", line 735, in next
    raise value
ValueError: zero-size array to reduction operation maximum which has no identity

Am I making a mistake somewhere? Thanks in advance!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:17

github_iconTop GitHub Comments

2reactions
cschaefer26commented, May 18, 2021

On a side note. If you need a better phonemizer, you could check out my new repo https://github.com/as-ideas/DeepPhonemizer. You will have to train your on phonemizer on an indian phoneme dataset. You could then use ForwarTacotron with ‘no_cleaners’ and ‘use_phonemes=False’.

0reactions
Jass-AGIcommented, May 19, 2021

Thanks for the clarification I’ll try to do the same.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why Adults Struggle To Learn A Second Language
Reasons Why Adults Learn A Second Language Harder Than Kids. However, conscious learning is characterized by the appalling forgetting curve ...
Read more >
16 language learning problems I struggle with every day
Struggling with language problems and frustrations? Me too, on a daily basis! Here are 16 of them with some solutions for you!
Read more >
Learning Languages - UNC Learning Center
Learning a new language involves listening, speaking, reading, writing, sometimes even a new alphabet and writing format. If you focus exclusively on just...
Read more >
How to Learn a New Language Fast: 18 Tips To Help You Go ...
Learn the translations first, then learn to produce the new words. Start by looking at the side of the flashcard with a foreign...
Read more >
5 Tips to Improve Your Foreign Language Skills - Go Overseas
Maybe you're facing one of these common language learning problems. Try our strategies and tips to help you overcome the hurdles to learning...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found