Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to disable WARNIGs? #154

Open
yihuitang opened this issue Jul 9, 2023 · 4 comments
Open

How to disable WARNIGs? #154

yihuitang opened this issue Jul 9, 2023 · 4 comments

Comments

@yihuitang
Copy link

yihuitang commented Jul 9, 2023

Hi,

I've set language_switch='remove-flags' and words_mismatch='ignore'. However, I still got warnings like below:

WARNING:phonemizer:1 utterances containing language switches on lines 1
WARNING:phonemizer:extra phones may appear in the "cmn" phoneset
WARNING:phonemizer:language switch flags have been removed (applying "remove-flags" policy)
WARNING:phonemizer:words count mismatch on 100.0% of the lines (1/1)
WARNING:phonemizer:1 utterances containing language switches on lines 1
WARNING:phonemizer:extra phones may appear in the "cmn" phoneset
WARNING:phonemizer:language switch flags have been removed (applying "remove-flags" policy)
WARNING:phonemizer:words count mismatch on 100.0% of the lines (1/1)

How can I disable warnings in my Python code?

@mmmaat
Copy link
Collaborator

mmmaat commented Jul 12, 2023

Just add the parameter logger=get_logger(verbosity='quiet')in the function call. See https://github.com/bootphon/phonemizer/blob/master/phonemizer/logger.py#L22.

@mmmaat mmmaat closed this as completed Jul 12, 2023
@yihuitang
Copy link
Author

yihuitang commented Jul 14, 2023

@mmmaat That didn't work. Here is my code:

    from phonemizer.logger import get_logger
....
    backend = EspeakBackend(language='cmn', language_switch='remove-flags',
                            words_mismatch='ignore',
                            punctuation_marks=punctuations, preserve_punctuation=True,
                            logger=get_logger(verbosity='quiet'))
...
    text = backend.phonemize(text_list, njobs=4,
                             separator=Separator(phone=' ', word=None, syllable='|'))

Warnings persist.

If I add the parameter logger=get_logger(verbosity='quiet') to phonemize(), I got an error:

TypeError: phonemize() got an unexpected keyword argument 'logger'

@mmmaat
Copy link
Collaborator

mmmaat commented Jul 18, 2023

I don't understand. I have

$ phonemize --version
phonemizer-3.2.1
available backends: espeak-ng-1.50, espeak-mbrola, festival-2.5.0, segments-2.2.1

Then in IPython interpreter (The sentence in French means 'I like football' with a language switch on the word 'football'):

In [1]: from phonemizer import phonemize
In [2]: from phonemizer.logger import get_logger
In [3]: phonemize("j'aime le football", language='fr-fr', backend='espeak', language_switch='remove-flags', logger=get_logger(verbosity='quiet'))
Out[3] : 'ʒɛm lə fʊtbɔːl '
In [4]: phonemize("j'aime le football", language='fr-fr', backend='espeak', language_switch='remove-flags', logger=get_logger(verbosity='normal'))
[WARNING] 1 utterances containing language switches on lines 1
[WARNING] extra phones may appear in the "fr-fr" phoneset
[WARNING] language switch flags have been removed (applying "remove-flags" policy)
Out[4]: 'ʒɛm lə fʊtbɔːl '

Can you reproduce that? What version of phonemizer do you use?

@mmmaat mmmaat reopened this Jul 18, 2023
@yihuitang
Copy link
Author

I have the same versions as you do. I can also reproduce what you got.

Looks like it is the following line in my code that overrides the logger setting in the phonemizer:

logging.basicConfig(stream=sys.stdout, level=logging.WARNING)

Tried to set level=logging.ERROR but it didn't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants