Spaces:
Running
Running
drewThomasson
commited on
Commit
•
66ccdd7
1
Parent(s):
d7b5eaf
Now has input text limit for cpu demo
Browse files
app.py
CHANGED
@@ -1,11 +1,24 @@
|
|
1 |
import gradio as gr
|
2 |
from outetts.v0_1.interface import InterfaceHF
|
|
|
3 |
|
4 |
# Initialize the TTS model interface
|
5 |
interface = InterfaceHF("OuteAI/OuteTTS-0.1-350M")
|
6 |
|
|
|
|
|
|
|
7 |
# Define a function to generate and save TTS output from input text
|
8 |
def generate_tts(text, temperature=0.1, repetition_penalty=1.1, max_length=4096):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
# Log user input and parameters in the terminal
|
10 |
print(f"User entered text: {text}")
|
11 |
print(f"Temperature set to: {temperature}")
|
@@ -66,4 +79,4 @@ with gr.Blocks() as demo:
|
|
66 |
)
|
67 |
|
68 |
print("Launching Gradio interface...")
|
69 |
-
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from outetts.v0_1.interface import InterfaceHF
|
3 |
+
import torch
|
4 |
|
5 |
# Initialize the TTS model interface
|
6 |
interface = InterfaceHF("OuteAI/OuteTTS-0.1-350M")
|
7 |
|
8 |
+
# Check if running on a CPU
|
9 |
+
is_cpu = not torch.cuda.is_available()
|
10 |
+
|
11 |
# Define a function to generate and save TTS output from input text
|
12 |
def generate_tts(text, temperature=0.1, repetition_penalty=1.1, max_length=4096):
|
13 |
+
# Set a character limit for the text input
|
14 |
+
max_characters = 30 # adjust as needed
|
15 |
+
|
16 |
+
# Check if input text exceeds character limit
|
17 |
+
if is_cpu and len(text) > max_characters:
|
18 |
+
raise gr.Error(
|
19 |
+
f"Text input is too long! Please limit to {max_characters} characters.\n This limit is in place to prevent long processing times as this interface is running on a free CPU tier."
|
20 |
+
)
|
21 |
+
|
22 |
# Log user input and parameters in the terminal
|
23 |
print(f"User entered text: {text}")
|
24 |
print(f"Temperature set to: {temperature}")
|
|
|
79 |
)
|
80 |
|
81 |
print("Launching Gradio interface...")
|
82 |
+
demo.launch()
|