skytnt commited on
Commit
eb91658
Β·
1 Parent(s): a4b3927

gradio 5.0.1

Browse files
Files changed (2) hide show
  1. README.md +1 -1
  2. app.py +11 -19
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: πŸ˜ŠπŸŽ™οΈ
4
  colorFrom: red
5
  colorTo: pink
6
  sdk: gradio
7
- sdk_version: 4.36.0
8
  app_file: app.py
9
  pinned: true
10
  license: mit
 
4
  colorFrom: red
5
  colorTo: pink
6
  sdk: gradio
7
+ sdk_version: 5.0.1
8
  app_file: app.py
9
  pinned: true
10
  license: mit
app.py CHANGED
@@ -2,22 +2,18 @@ import argparse
2
  import json
3
  import os
4
  import re
5
- import tempfile
6
- from pathlib import Path
7
 
 
8
  import librosa
9
  import numpy as np
10
  import torch
11
- from gradio import FileData
12
  from torch import no_grad, LongTensor
 
13
  import commons
14
  import utils
15
- import gradio as gr
16
- import gradio.utils as gr_utils
17
- import gradio_client.utils as gr_processing_utils
18
  from models import SynthesizerTrn
19
  from text import text_to_sequence, _clean_text
20
- from mel_processing import spectrogram_torch
21
 
22
  limitation = os.getenv("SYSTEM") == "spaces" # limit text and audio length in huggingface spaces
23
 
@@ -59,9 +55,6 @@ def create_vc_fn(model, hps, speaker_ids):
59
  if input_audio is None:
60
  return "You need to upload an audio", None
61
  sampling_rate, audio = input_audio
62
- duration = audio.shape[0] / sampling_rate
63
- if limitation and duration > 30:
64
- return "Error: Audio is too long", None
65
  original_speaker_id = speaker_ids[original_speaker]
66
  target_speaker_id = speaker_ids[target_speaker]
67
 
@@ -92,9 +85,6 @@ def create_soft_vc_fn(model, hps, speaker_ids):
92
  if input_audio is None:
93
  return "You need to upload an audio", None
94
  sampling_rate, audio = input_audio
95
- duration = audio.shape[0] / sampling_rate
96
- if limitation and duration > 30:
97
- return "Error: Audio is too long", None
98
  target_speaker_id = speaker_ids[target_speaker]
99
 
100
  audio = (audio / np.iinfo(audio.dtype).max).astype(np.float32)
@@ -186,12 +176,12 @@ if __name__ == '__main__':
186
  to_symbol_fn) in enumerate(models_tts):
187
  with gr.TabItem(f"model{i}"):
188
  with gr.Column():
189
- cover_markdown = f"![cover](file/{cover_path})\n\n" if cover_path else ""
190
  gr.Markdown(f"## {name}\n\n"
191
  f"{cover_markdown}"
192
  f"model author: {author}\n\n"
193
  f"language: {lang}")
194
- tts_input1 = gr.TextArea(label="Text (150 words limitation)", value=example,
195
  elem_id=f"tts-input{i}")
196
  tts_input2 = gr.Dropdown(label="Speaker", choices=speakers,
197
  type="index", value=speakers[0])
@@ -237,7 +227,7 @@ if __name__ == '__main__':
237
  with gr.Tabs():
238
  for i, (name, author, cover_path, speakers, vc_fn) in enumerate(models_vc):
239
  with gr.TabItem(f"model{i}"):
240
- cover_markdown = f"![cover](file/{cover_path})\n\n" if cover_path else ""
241
  gr.Markdown(f"## {name}\n\n"
242
  f"{cover_markdown}"
243
  f"model author: {author}")
@@ -245,7 +235,8 @@ if __name__ == '__main__':
245
  value=speakers[0])
246
  vc_input2 = gr.Dropdown(label="Target Speaker", choices=speakers, type="index",
247
  value=speakers[min(len(speakers) - 1, 1)])
248
- vc_input3 = gr.Audio(label="Input Audio (30s limitation)")
 
249
  vc_submit = gr.Button("Convert", variant="primary")
250
  vc_output1 = gr.Textbox(label="Output Message")
251
  vc_output2 = gr.Audio(label="Output Audio", elem_id=f"vc-audio{i}")
@@ -255,13 +246,14 @@ if __name__ == '__main__':
255
  with gr.Tabs():
256
  for i, (name, author, cover_path, speakers, soft_vc_fn) in enumerate(models_soft_vc):
257
  with gr.TabItem(f"model{i}"):
258
- cover_markdown = f"![cover](file/{cover_path})\n\n" if cover_path else ""
259
  gr.Markdown(f"## {name}\n\n"
260
  f"{cover_markdown}"
261
  f"model author: {author}")
262
  vc_input1 = gr.Dropdown(label="Target Speaker", choices=speakers, type="index",
263
  value=speakers[0])
264
- vc_input2 = gr.Audio(label="Input Audio (30s limitation)")
 
265
  vc_submit = gr.Button("Convert", variant="primary")
266
  vc_output1 = gr.Textbox(label="Output Message")
267
  vc_output2 = gr.Audio(label="Output Audio", elem_id=f"svc-audio{i}")
 
2
  import json
3
  import os
4
  import re
 
 
5
 
6
+ import gradio as gr
7
  import librosa
8
  import numpy as np
9
  import torch
 
10
  from torch import no_grad, LongTensor
11
+
12
  import commons
13
  import utils
14
+ from mel_processing import spectrogram_torch
 
 
15
  from models import SynthesizerTrn
16
  from text import text_to_sequence, _clean_text
 
17
 
18
  limitation = os.getenv("SYSTEM") == "spaces" # limit text and audio length in huggingface spaces
19
 
 
55
  if input_audio is None:
56
  return "You need to upload an audio", None
57
  sampling_rate, audio = input_audio
 
 
 
58
  original_speaker_id = speaker_ids[original_speaker]
59
  target_speaker_id = speaker_ids[target_speaker]
60
 
 
85
  if input_audio is None:
86
  return "You need to upload an audio", None
87
  sampling_rate, audio = input_audio
 
 
 
88
  target_speaker_id = speaker_ids[target_speaker]
89
 
90
  audio = (audio / np.iinfo(audio.dtype).max).astype(np.float32)
 
176
  to_symbol_fn) in enumerate(models_tts):
177
  with gr.TabItem(f"model{i}"):
178
  with gr.Column():
179
+ cover_markdown = f"![cover](gradio_api/file={cover_path})\n\n" if cover_path else ""
180
  gr.Markdown(f"## {name}\n\n"
181
  f"{cover_markdown}"
182
  f"model author: {author}\n\n"
183
  f"language: {lang}")
184
+ tts_input1 = gr.TextArea(label="Text (150 chars limitation)", value=example,
185
  elem_id=f"tts-input{i}")
186
  tts_input2 = gr.Dropdown(label="Speaker", choices=speakers,
187
  type="index", value=speakers[0])
 
227
  with gr.Tabs():
228
  for i, (name, author, cover_path, speakers, vc_fn) in enumerate(models_vc):
229
  with gr.TabItem(f"model{i}"):
230
+ cover_markdown = f"![cover](gradio_api/file={cover_path})\n\n" if cover_path else ""
231
  gr.Markdown(f"## {name}\n\n"
232
  f"{cover_markdown}"
233
  f"model author: {author}")
 
235
  value=speakers[0])
236
  vc_input2 = gr.Dropdown(label="Target Speaker", choices=speakers, type="index",
237
  value=speakers[min(len(speakers) - 1, 1)])
238
+ vc_input3 = gr.Audio(label="Input Audio",
239
+ max_length=30 if limitation else None)
240
  vc_submit = gr.Button("Convert", variant="primary")
241
  vc_output1 = gr.Textbox(label="Output Message")
242
  vc_output2 = gr.Audio(label="Output Audio", elem_id=f"vc-audio{i}")
 
246
  with gr.Tabs():
247
  for i, (name, author, cover_path, speakers, soft_vc_fn) in enumerate(models_soft_vc):
248
  with gr.TabItem(f"model{i}"):
249
+ cover_markdown = f"![cover](gradio_api/file={cover_path})\n\n" if cover_path else ""
250
  gr.Markdown(f"## {name}\n\n"
251
  f"{cover_markdown}"
252
  f"model author: {author}")
253
  vc_input1 = gr.Dropdown(label="Target Speaker", choices=speakers, type="index",
254
  value=speakers[0])
255
+ vc_input2 = gr.Audio(label="Input Audio",
256
+ max_length=30 if limitation else None)
257
  vc_submit = gr.Button("Convert", variant="primary")
258
  vc_output1 = gr.Textbox(label="Output Message")
259
  vc_output2 = gr.Audio(label="Output Audio", elem_id=f"svc-audio{i}")