Skip to content

Commit

Permalink
added max len char
Browse files Browse the repository at this point in the history
  • Loading branch information
huseinzol05 committed Dec 10, 2024
1 parent 89328c2 commit 61d2532
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions gradio/f5-tts/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
overlap_length = None
speech_enhancement_hop_length = None

maxlen_text = int(os.environ.get('MAXLEN_TEXT', '1000'))
maxlen = 20000
maxlen_str = f'{maxlen // 1000} seconds'

Expand Down Expand Up @@ -178,6 +179,9 @@ def basic_tts(
if len(gen_text_input) < 2:
raise gr.Error(f"Text to generate is too short.")

if len(gen_text_input) >= maxlen_text:
raise gr.Error(f"Text to generate is more than {maxlen_text} characters, for fair public use, we limit it, feel free to self host.")

torch.cuda.empty_cache()

with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as f:
Expand Down Expand Up @@ -324,6 +328,8 @@ def basic_tts(
If you're having issues, try converting your reference audio to WAV or MP3, clipping it to {maxlen_str} with ✂ in the bottom right corner (otherwise might have non-optimal auto-trimmed result).
**Reference text will be automatically transcribed with Whisper if not provided. For best results, keep your reference clips shorter than {maxlen_str}. Ensure the audio is fully uploaded before generating.**
**For fair public use, we limit the maximum to {maxlen_text} characters only.**
"""
)
ref_audio_input = gr.Audio(label="Reference Audio", type="filepath")
Expand Down
2 changes: 1 addition & 1 deletion gradio/f5-tts/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ services:
- "~/.cache/huggingface:/root/.cache/huggingface"
environment:
- HOTLOAD=true
command: gradio app.py
command: python3 app.py

0 comments on commit 61d2532

Please sign in to comment.