hexgrad commited on
Commit
480b27e
โ€ข
1 Parent(s): 1daab5c

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -109,9 +109,10 @@ VOCAB = get_vocab()
109
  def tokenize(ps):
110
  return [i for i in map(VOCAB.get, ps) if i is not None]
111
 
112
- # ๐Ÿงช indicates that voices are experimental
 
113
  CHOICES = {
114
- '๐Ÿ‡บ๐Ÿ‡ธ ๐Ÿšบ Gladiatrix โš”๏ธ': 'af_gladiatrix',
115
  '๐Ÿ‡บ๐Ÿ‡ธ ๐Ÿšบ American Female 0': 'af_0',
116
  '๐Ÿ‡บ๐Ÿ‡ธ ๐Ÿšบ Alloy ๐Ÿงช': 'af_alloy',
117
  '๐Ÿ‡บ๐Ÿ‡ธ ๐Ÿšบ Bella': 'af_bella',
@@ -181,7 +182,7 @@ def forward(tokens, voice, speed):
181
  def generate(text, voice, ps=None, speed=1.0, reduce_noise=0.5, opening_cut=4000, closing_cut=2000, ease_in=3000, ease_out=1000, pad_before=5000, pad_after=5000):
182
  if voice not in VOICES:
183
  # Ensure stability for https://huggingface.co/spaces/Pendrokar/TTS-Spaces-Arena
184
- voice = 'af_gladiatrix'
185
  ps = ps or phonemize(text, voice)
186
  tokens = tokenize(ps)
187
  if not tokens:
@@ -222,7 +223,7 @@ with gr.Blocks() as basic_tts:
222
  with gr.Row():
223
  with gr.Column():
224
  text = gr.Textbox(label='Input Text')
225
- voice = gr.Dropdown(list(CHOICES.items()), label='Voice', info='๐Ÿงช Experimental voices may be unstable.')
226
  with gr.Row():
227
  random_btn = gr.Button('Random Text', variant='secondary')
228
  generate_btn = gr.Button('Generate', variant='primary')
@@ -405,7 +406,7 @@ with gr.Blocks() as lf_tts:
405
  file_input = gr.File(file_types=['.pdf', '.txt'], label='Input File: pdf or txt')
406
  text = gr.Textbox(label='Input Text')
407
  file_input.upload(fn=extract_text, inputs=[file_input], outputs=[text])
408
- voice = gr.Dropdown(list(CHOICES.items()), label='Voice', info='๐Ÿงช Experimental voices may be unstable.')
409
  with gr.Accordion('Text Settings', open=False):
410
  skip_square_brackets = gr.Checkbox(True, label='Skip [Square Brackets]', info='Recommended for academic papers, Wikipedia articles, or texts with citations.')
411
  newline_split = gr.Number(2, label='Newline Split', info='Split the input text on this many newlines. Affects how the text is segmented.', precision=0, minimum=0)
@@ -487,7 +488,7 @@ client = Client('hexgrad/Kokoro-TTS')
487
  # 3. Call the generate endpoint, which returns a pair: an audio path and a string of output phonemes
488
  audio_path, out_ps = client.predict(
489
  text="How could I know? It's an unanswerable question. Like asking an unborn child if they'll lead a good life. They haven't even been born.",
490
- voice='af_gladiatrix',
491
  api_name='/generate'
492
  )
493
 
 
109
  def tokenize(ps):
110
  return [i for i in map(VOCAB.get, ps) if i is not None]
111
 
112
+ # ๐Ÿงช Experimental voices may be unstable.
113
+ # โš”๏ธ Arena voices are averages of other voices.
114
  CHOICES = {
115
+ '๐Ÿ‡บ๐Ÿ‡ธ ๐Ÿšบ American Female โš”๏ธ': 'af',
116
  '๐Ÿ‡บ๐Ÿ‡ธ ๐Ÿšบ American Female 0': 'af_0',
117
  '๐Ÿ‡บ๐Ÿ‡ธ ๐Ÿšบ Alloy ๐Ÿงช': 'af_alloy',
118
  '๐Ÿ‡บ๐Ÿ‡ธ ๐Ÿšบ Bella': 'af_bella',
 
182
  def generate(text, voice, ps=None, speed=1.0, reduce_noise=0.5, opening_cut=4000, closing_cut=2000, ease_in=3000, ease_out=1000, pad_before=5000, pad_after=5000):
183
  if voice not in VOICES:
184
  # Ensure stability for https://huggingface.co/spaces/Pendrokar/TTS-Spaces-Arena
185
+ voice = 'af'
186
  ps = ps or phonemize(text, voice)
187
  tokens = tokenize(ps)
188
  if not tokens:
 
223
  with gr.Row():
224
  with gr.Column():
225
  text = gr.Textbox(label='Input Text')
226
+ voice = gr.Dropdown(list(CHOICES.items()), label='Voice', info='๐Ÿงช Experimental voices may be unstable. โš”๏ธ Arena voices are averages of other voices.')
227
  with gr.Row():
228
  random_btn = gr.Button('Random Text', variant='secondary')
229
  generate_btn = gr.Button('Generate', variant='primary')
 
406
  file_input = gr.File(file_types=['.pdf', '.txt'], label='Input File: pdf or txt')
407
  text = gr.Textbox(label='Input Text')
408
  file_input.upload(fn=extract_text, inputs=[file_input], outputs=[text])
409
+ voice = gr.Dropdown(list(CHOICES.items()), label='Voice', info='๐Ÿงช Experimental voices may be unstable. โš”๏ธ Arena voices are averages of other voices.')
410
  with gr.Accordion('Text Settings', open=False):
411
  skip_square_brackets = gr.Checkbox(True, label='Skip [Square Brackets]', info='Recommended for academic papers, Wikipedia articles, or texts with citations.')
412
  newline_split = gr.Number(2, label='Newline Split', info='Split the input text on this many newlines. Affects how the text is segmented.', precision=0, minimum=0)
 
488
  # 3. Call the generate endpoint, which returns a pair: an audio path and a string of output phonemes
489
  audio_path, out_ps = client.predict(
490
  text="How could I know? It's an unanswerable question. Like asking an unborn child if they'll lead a good life. They haven't even been born.",
491
+ voice='af',
492
  api_name='/generate'
493
  )
494