Spaces:
Running
Running
drewThomasson
commited on
Commit
•
f5506fc
1
Parent(s):
d084eaa
Update app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,13 @@ 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 |
output = interface.generate(
|
10 |
text=text,
|
11 |
temperature=temperature,
|
@@ -14,21 +21,37 @@ def generate_tts(text, temperature=0.1, repetition_penalty=1.1, max_length=4096)
|
|
14 |
)
|
15 |
# Save the output audio to a file
|
16 |
output.save("output.wav")
|
|
|
|
|
17 |
return "output.wav"
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
# Gradio interface for TTS
|
20 |
demo = gr.Interface(
|
21 |
fn=generate_tts,
|
22 |
inputs=[
|
23 |
-
gr.Textbox(lines=2, placeholder="Enter text to convert to speech", label="Text"),
|
24 |
-
gr.Slider(0.1, 1.0, value=0.1, label="Temperature"),
|
25 |
-
gr.Slider(1.0, 2.0, value=1.1, label="Repetition Penalty"),
|
26 |
-
gr.Slider(512, 4096, value=4096, step=256, label="Max Length")
|
27 |
],
|
28 |
-
outputs=gr.Audio(type="
|
29 |
title="OuteTTS Text-to-Speech Demo",
|
30 |
description="Convert text to speech using the OuteTTS model."
|
31 |
)
|
32 |
|
33 |
# Launch the Gradio app
|
|
|
34 |
demo.launch()
|
|
|
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}")
|
12 |
+
print(f"Repetition Penalty set to: {repetition_penalty}")
|
13 |
+
print(f"Max Length set to: {max_length}")
|
14 |
+
|
15 |
+
# Generate TTS output
|
16 |
output = interface.generate(
|
17 |
text=text,
|
18 |
temperature=temperature,
|
|
|
21 |
)
|
22 |
# Save the output audio to a file
|
23 |
output.save("output.wav")
|
24 |
+
print("Audio generated and saved as output.wav")
|
25 |
+
|
26 |
return "output.wav"
|
27 |
|
28 |
+
# Define callback functions for interaction logging
|
29 |
+
def on_text_input(text):
|
30 |
+
print(f"User typed text: {text}")
|
31 |
+
|
32 |
+
def on_temperature_change(val):
|
33 |
+
print(f"Temperature slider adjusted to: {val}")
|
34 |
+
|
35 |
+
def on_repetition_penalty_change(val):
|
36 |
+
print(f"Repetition Penalty slider adjusted to: {val}")
|
37 |
+
|
38 |
+
def on_max_length_change(val):
|
39 |
+
print(f"Max Length slider adjusted to: {val}")
|
40 |
+
|
41 |
# Gradio interface for TTS
|
42 |
demo = gr.Interface(
|
43 |
fn=generate_tts,
|
44 |
inputs=[
|
45 |
+
gr.Textbox(lines=2, placeholder="Enter text to convert to speech", label="Text").change(on_text_input),
|
46 |
+
gr.Slider(0.1, 1.0, value=0.1, label="Temperature").change(on_temperature_change),
|
47 |
+
gr.Slider(1.0, 2.0, value=1.1, label="Repetition Penalty").change(on_repetition_penalty_change),
|
48 |
+
gr.Slider(512, 4096, value=4096, step=256, label="Max Length").change(on_max_length_change)
|
49 |
],
|
50 |
+
outputs=gr.Audio(type="filepath", label="Generated Speech"),
|
51 |
title="OuteTTS Text-to-Speech Demo",
|
52 |
description="Convert text to speech using the OuteTTS model."
|
53 |
)
|
54 |
|
55 |
# Launch the Gradio app
|
56 |
+
print("Launching Gradio interface...")
|
57 |
demo.launch()
|