
    11i4                        S r SSKrSSKrSSKJr  SSKJrJrJrJ	r	  SSK
Jr  SSKJr  SSKJr  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJrJr  SSKJrJr  \S   r0 rSS\SSSS\R@                  " 5       SSSSS\" 5       4S\!S\S\\   S\"S\"S\"S\"S\\!\	4   S\"S\\"\!4   S\S \S!\#S"\4S# jjr$S\S\"S\\"\!4   S\S\S \4S$ jr%S\S%\\!\\!   4   S\S\"S!\#S\"S\"4S& jr&g)'zjProvides the phonemize function

To use it in your own code, type:

    from phonemizer import phonemize

    N)Logger)OptionalUnionListPattern)Literal)BACKENDS)BaseBackend)LanguageSwitch)WordMismatch)
get_logger)Punctuation)default_separator	Separator)list2strstr2listespeakespeak-mbrolafestivalsegmentszen-usr   F
keep-flagsignore   languagebackend	separatorstripprepend_textpreserve_empty_linespreserve_punctuationpunctuation_markswith_stresstielanguage_switchwords_mismatchnjobsloggerc                 @   [         R                  S:  a/  UR                  SSR                  [         R                  5      5        [	        X)XX5        US:X  a  U(       a  UR                  S5        US:X  a"  UR                  (       a  UR                  S5        UU[        U5      UU	U
UU4nU[        ;   a  [        [        U   XXMXV5      $ US:X  a  [        U   " UUUU	U
UUUS9nU[        U'   O%US:X  a  [        U   " UUS	9nO[        U   " UUUUS
9n[        UXXMXV5      $ )u
  Multilingual text to phonemes converter

Return a phonemized version of an input `text`, given its `language` and a
phonemization `backend`.

Note
----

To improve the processing speed it is better to minimize the calls to this
function: provide the input text as a list and call phonemize() a single
time is much more efficient than calling it on each element of the list.
Indeed the initialization of the phonemization backend can be expensive,
especially for espeak. In one example,

Do this:

>>> text = [line1, line2, ...]
>>> phonemize(text, ...)

Not this:

>>> for line in text:
>>>     phonemize(line, ...)

Parameters
----------

text: str or list of str
    The text to be phonemized. Any empty line will
    be ignored. If ``text`` is an str, it can be multiline (lines being
    separated by ``\n``). If ``text`` is a list, each element is considered as a
    separated line. Each line is considered as a text utterance.

language: str
    The language code of the input text, must be supported by
    the backend. If ``backend`` is 'segments', the language can be a file with
    a grapheme to phoneme mapping.

backend: str, optional
    The software backend to use for phonemization,
    must be 'festival' (US English only is supported, coded 'en-us'),
    'espeak', 'espeak-mbrola' or 'segments'.

separator: Separator
    string separators between phonemes, syllables and
    words, default to separator.default_separator. Syllable separator is
    considered only for the festival backend. Word separator is ignored by
    the 'espeak-mbrola' backend. Initialize it as follows:
        >>> from phonemizer.separator import Separator
        >>> separator = Separator(phone='-', word=' ')

strip: bool, optional
    If True, don't output the last word and phone
    separators of a token, default to False.

prepend_text: bool, optional
    When True, returns a pair (input utterance,
    phonemized utterance) for each line of the input text. When False,
    returns only the phonemized utterances. Default to False

preserve_empty_lines: bool, optional
    When True, will keep the empty lines
    in the phonemized output. Default to False and remove all empty lines.

preserve_punctuation: bool, optional
    When True, will keep the punctuation
    in the phonemized output. Not supported by the 'espeak-mbrola' backend.
    Default to False and remove all the punctuation.

punctuation_marks: str or re.Pattern, optional
    The punctuation marks to consider when dealing with punctuation,
    either for removal or preservation.  Can be defined as a string or regular expression.
    Default to Punctuation.default_marks().

with_stress: bool, optional
    This option is only valid for the 'espeak'
    backend. When True the stresses on phonemes are present (stresses
    characters are ˈ'ˌ). When False stresses are removed. Default to False.

tie: bool or char, optional
    This option is only valid for the 'espeak'
    backend with espeak>=1.49. It is incompatible with phone separator. When
    not False, use a tie character within multi-letter phoneme names. When
    True, the char 'U+361' is used (as in d͡ʒ), 'z' means ZWJ character,
    default to False.

language_switch: str, optional
    Espeak can output some words in another
    language (typically English) when phonemizing a text. This option setups
    the policy to use when such a language switch occurs. Three values are
    available : 'keep-flags' (the default), 'remove-flags' or
    'remove-utterance'. The 'keep-flags' policy keeps the language switching
    flags, for example "(en) or (jp)", in the output. The 'remove-flags'
    policy removes them and the 'remove-utterance' policy removes the whole
    line of text including a language switch. This option is only valid for
    the 'espeak' backend.

words_mismatch: str, optional
    Espeak can join two consecutive words or
    drop some words, yielding a word count mismatch between orthographic and
    phonemized text. This option setups the policy to use when such a words
    count mismatch occurs. Three values are available: 'ignore' (the default)
    which do nothing, 'warn' which issue a warning for each mismatched line,
    and 'remove' which remove the mismatched lines from the output.

njobs: int
    The number of parallel jobs to launch. The input text is split
    in ``njobs`` parts, phonemized on parallel instances of the backend and the
    outputs are finally collapsed.

logger: logging.Logger
    the logging instance where to send messages. If
    not specified, use the default system logger.

Returns
-------
phonemized text: str or list of str
    The input ``text`` phonemized for the
    given ``language`` and ``backend``. The returned value has the same type of
    the input text (either a list or a string), excepted if ``prepend_input``
    is True where the output is forced as a list of pairs (input_text,
    phonemized text).

Raises
------
RuntimeError
    if the ``backend`` is not valid or is valid but not installed,
    if the ``language`` is not supported by the ``backend``, if any incompatible options are used.

)      z]Your are using python-%s which is unsupported by the phonemizer, please update to python>=3.6.r   z1espeak-mbrola backend cannot preserve punctuationz5espeak-mbrola backend cannot preserve word separationr   )r"   r!   r#   r$   r%   r&   r(   )r(   )r"   r!   r(   )sysversion_infoerrorjoin_check_argumentswarningwordstr_PHONEMIZER_CACHE
_phonemizer	   )textr   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   	cache_key
phonemizers                    N/home/james-whalen/.local/lib/python3.13/site-packages/phonemizer/phonemize.py	phonemizer;   +   sS   f & +,/HHS5E5E,F	H
 coO /!&:JK/!innNO
 		I %%+I6Wczz (g&/!5#+)
 (2)$	O	#g&
 g&/!5	
 j$5dd    c                    U S;  a*  [        SR                  U SR                  S5      5      5      eU(       a   U S:w  a  [        SR                  U 5      5      eU(       a   U S:w  a  [        SR                  U 5      5      eU(       a*  UR                  (       a  [        SUR                   S35      eUS	:w  a   U S:w  a  [        S
R                  U 5      5      eUS:w  a!  U S:w  a  [        SR                  U 5      5      egg)zAuxiliary function to phonemize()

Ensures the parameters are compatible with each other, raises a
RuntimeError the first encountered error.

r   z,{} is not a supported backend, choose in {}.z, r   z[the "with_stress" option is available for espeak backend only, but you are using {} backendzSthe "tie" option is available for espeak backend only, but you are using {} backendzAthe "tie" option is incompatible with phone separator (which is "z")r   z_the "language_switch" option is available for espeak backend only, but you are using {} backendr   z^the "words_mismatch" option is available for espeak backend only, but you are using {} backendN)RuntimeErrorformatr0   phone)r   r#   r$   r   r%   r&   s         r:   r1   r1      s    II:C"E FG 	G w(*++16'?< 	<
 w("++16'?< 	<
 y#//*"./ 	/
 ,&7h+>117B 	B
 !g&9117B 	B ':!r<   r7   c                 ~   [        U5      n[        U5       Vs/ s H!  oR                  [        R                  5      PM#     nnU(       a6  [        U5       V	Vs/ s H  u  pUR                  5       (       a  M  U	PM      n
n	nU Vs/ s H  oR                  5       (       d  M  UPM     nnU(       a  U R                  XX4S9nO/ nU(       a4  W
 H.  nU(       a  UR                  US5        UR                  US5        M0     U(       a  [        [        X5      5      $ U[        :X  a  [        U5      $ U$ s  snf s  snn	f s  snf )z|Auxiliary function to phonemize()

Does the phonemization and returns the phonemized text. Raises a
RuntimeError on error.

)r   r   r'    )typer   r   oslinesep	enumerater;   insertlistzipr4   r   )r   r7   r   r   r'   r   r    	text_typelinenempty_lines
phonemizedis                r:   r6   r6   ,  s    T
I 08~>~tJJrzz"~D> (1$LWQtzz|qL "2TTZZ\DTD2&&U ' A
 
 AAr"a$  C)**C
##; ? M 3s   (D/D47D4D: D:)'__doc__rD   r-   loggingr   typingr   r   r   r   typing_extensionsr   phonemizer.backendr	   phonemizer.backend.baser
   )phonemizer.backend.espeak.language_switchr   (phonemizer.backend.espeak.words_mismatchr   phonemizer.loggerr   phonemizer.punctuationr   phonemizer.separatorr   r   phonemizer.utilsr   r   Backendr5   default_marksr4   boolintr;   r1   r6    r<   r:   <module>ra      s   
 
  1 1 % ' / D A ( . = /
C
D 
  #):"%*%*1<1J1J1L! %*6'/#KeKe Ke I&	Ke
 Ke Ke #Ke #Ke !g.Ke Ke 49Ke (Ke %Ke Ke Ke\0B0B0B 490B 	0B
 (0B %0Bf//CcN#/ / 	/
 / / #/r<   