wetdog commited on
Commit
67673a1
·
1 Parent(s): c8b6889

Fix inference, setup global phonemizers and update requirements

Browse files
Files changed (2) hide show
  1. app.py +44 -9
  2. requirements.txt +3 -3
app.py CHANGED
@@ -1,24 +1,59 @@
1
  import gradio as gr
2
  import os
3
  from AinaTheme import theme
4
- from espeak_phonemizer import Phonemizer
5
  from dotenv import load_dotenv
 
6
 
7
  load_dotenv()
8
 
9
  MAX_INPUT_TEXT_LEN = int(os.environ.get("MAX_INPUT_TEXT_LEN", default=325))
10
 
11
- #fonemitzador = Phonemizer("ca")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
  def phonemiser(text, dialect):
14
- dialects = {"Central": "ca", "Valencian": "ca-va", "North-West": "ca-nw", "Balear": "ca-ba"}
15
- dialect = dialects[dialect] #Define dialect from espeak-ng-data/lang/roa/ca*
16
- fonemitzador = Phonemizer(dialect) #Set correct dialect for the phonemiser
17
-
 
 
18
  # synthesize
19
-
20
- fonemes = fonemitzador.phonemize(text, keep_clause_breakers=True)
21
-
22
  return fonemes
23
 
24
 
 
1
  import gradio as gr
2
  import os
3
  from AinaTheme import theme
4
+ import phonemizer
5
  from dotenv import load_dotenv
6
+ import logging
7
 
8
  load_dotenv()
9
 
10
  MAX_INPUT_TEXT_LEN = int(os.environ.get("MAX_INPUT_TEXT_LEN", default=325))
11
 
12
+ critical_logger = logging.getLogger("phonemizer")
13
+ critical_logger.setLevel(logging.CRITICAL)
14
+
15
+ # init phonemizers
16
+ global_phonemizer_central = phonemizer.backend.EspeakBackend(
17
+ language="ca",
18
+ preserve_punctuation=True,
19
+ with_stress=True,
20
+ language_switch="remove-flags",
21
+ logger=critical_logger,
22
+ )
23
+
24
+ global_phonemizer_valencia = phonemizer.backend.EspeakBackend(
25
+ language="ca-va",
26
+ preserve_punctuation=True,
27
+ with_stress=True,
28
+ language_switch="remove-flags",
29
+ logger=critical_logger,
30
+ )
31
+
32
+ global_phonemizer_occidental = phonemizer.backend.EspeakBackend(
33
+ language="ca-nw",
34
+ preserve_punctuation=True,
35
+ with_stress=True,
36
+ language_switch="remove-flags",
37
+ logger=critical_logger,
38
+ )
39
+
40
+ global_phonemizer_balear = phonemizer.backend.EspeakBackend(
41
+ language="ca-ba",
42
+ preserve_punctuation=True,
43
+ with_stress=True,
44
+ language_switch="remove-flags",
45
+ logger=critical_logger,
46
+ )
47
 
48
  def phonemiser(text, dialect):
49
+ phonemizers = {"Central": global_phonemizer_central,
50
+ "Valencian": global_phonemizer_valencia,
51
+ "North-West": global_phonemizer_occidental,
52
+ "Balear": global_phonemizer_balear}
53
+
54
+ fonemitzador = phonemizers[dialect] #Set correct dialect for the phonemiser
55
  # synthesize
56
+ fonemes = fonemitzador.phonemize([text], strip=True, njobs=1)[0]
 
 
57
  return fonemes
58
 
59
 
requirements.txt CHANGED
@@ -1,4 +1,4 @@
1
- aina-gradio-theme==2.0
2
- gradio==4.0.0
3
- espeak-phonemizer>=1.1.0,<2
4
  python-dotenv==1.0.0
 
1
+ aina-gradio-theme
2
+ gradio
3
+ phonemizer
4
  python-dotenv==1.0.0