ButterCream commited on
Commit
a835dc1
·
1 Parent(s): b1f9cb6

swap to VoPho phonemizer

Browse files
Files changed (2) hide show
  1. app.py +3 -10
  2. requirements.txt +2 -1
app.py CHANGED
@@ -5,14 +5,13 @@ import re
5
  import numpy as np
6
  from scipy.io.wavfile import write
7
  import nltk
 
8
 
9
  nltk.download('punkt')
10
  from nltk.tokenize import word_tokenize
11
 
12
  import torch
13
 
14
- import phonemizer # en-us
15
-
16
  INTRO = """
17
  <style>
18
 
@@ -94,13 +93,6 @@ theme = gr.themes.Soft(
94
  block_background_fill='*neutral_50'
95
  )
96
 
97
- # eventually swap to something else
98
- global_phonemizer = phonemizer.backend.EspeakBackend(language='en-us',
99
- preserve_punctuation=True,
100
- with_stress=True,
101
- language_switch="remove-flags",
102
- tie=False)
103
-
104
 
105
  def split_and_recombine_text(text, desired_length=200, max_length=300):
106
  """Split text it into chunks of a desired length trying to keep sentences intact."""
@@ -173,11 +165,12 @@ def split_and_recombine_text(text, desired_length=200, max_length=300):
173
 
174
  return rv
175
 
 
176
 
177
  def text_to_phonemes(text):
178
  text = text.strip()
179
  print("Text before phonemization: ", text)
180
- ps = global_phonemizer.phonemize([text])
181
  print("Text after phonemization: ", ps)
182
  ps = word_tokenize(ps[0])
183
  ps = ' '.join(ps)
 
5
  import numpy as np
6
  from scipy.io.wavfile import write
7
  import nltk
8
+ from VoPho.engine import Phonemizer
9
 
10
  nltk.download('punkt')
11
  from nltk.tokenize import word_tokenize
12
 
13
  import torch
14
 
 
 
15
  INTRO = """
16
  <style>
17
 
 
93
  block_background_fill='*neutral_50'
94
  )
95
 
 
 
 
 
 
 
 
96
 
97
  def split_and_recombine_text(text, desired_length=200, max_length=300):
98
  """Split text it into chunks of a desired length trying to keep sentences intact."""
 
165
 
166
  return rv
167
 
168
+ engine = Phonemizer()
169
 
170
  def text_to_phonemes(text):
171
  text = text.strip()
172
  print("Text before phonemization: ", text)
173
+ ps = engine.phonemize(text)
174
  print("Text after phonemization: ", ps)
175
  ps = word_tokenize(ps[0])
176
  ps = ' '.join(ps)
requirements.txt CHANGED
@@ -23,4 +23,5 @@ gradio
23
  spaces
24
  gruut
25
  txtsplit
26
- scipy
 
 
23
  spaces
24
  gruut
25
  txtsplit
26
+ scipy
27
+ VoPho