Dupaja commited on
Commit
4825e21
1 Parent(s): c6292d7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -0
app.py CHANGED
@@ -4,6 +4,7 @@ import torch
4
  import numpy as np
5
  import styletts2importable
6
  import re
 
7
 
8
  def split_and_recombine_text(text, desired_length=200, max_length=400):
9
  """Split text it into chunks of a desired length trying to keep sentences intact."""
@@ -80,6 +81,14 @@ theme = gr.themes.Base(
80
  font=[gr.themes.GoogleFont('Libre Franklin'), gr.themes.GoogleFont('Public Sans'), 'system-ui', 'sans-serif'],
81
  )
82
 
 
 
 
 
 
 
 
 
83
  def synthesize(text, voice, lngsteps, password, progress=gr.Progress()):
84
  if text.strip() == "":
85
  raise gr.Error("You must enter some text")
 
4
  import numpy as np
5
  import styletts2importable
6
  import re
7
+ import phonemizer
8
 
9
  def split_and_recombine_text(text, desired_length=200, max_length=400):
10
  """Split text it into chunks of a desired length trying to keep sentences intact."""
 
81
  font=[gr.themes.GoogleFont('Libre Franklin'), gr.themes.GoogleFont('Public Sans'), 'system-ui', 'sans-serif'],
82
  )
83
 
84
+ voicelist = ['f-us-1', 'f-us-2', 'f-us-3', 'f-us-4', 'm-us-1', 'm-us-2', 'm-us-3', 'm-us-4']
85
+ voices = {}
86
+
87
+ global_phonemizer = phonemizer.backend.EspeakBackend(language='en-us', preserve_punctuation=True, with_stress=True)
88
+
89
+ for v in voicelist:
90
+ voices[v] = styletts2importable.compute_style(f'voices/{v}.wav')
91
+
92
  def synthesize(text, voice, lngsteps, password, progress=gr.Progress()):
93
  if text.strip() == "":
94
  raise gr.Error("You must enter some text")