drewThomasson commited on
Commit
d7b5eaf
1 Parent(s): f5506fc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -28
app.py CHANGED
@@ -25,33 +25,45 @@ def generate_tts(text, temperature=0.1, repetition_penalty=1.1, max_length=4096)
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()
 
25
 
26
  return "output.wav"
27
 
28
+ # Create the Gradio Blocks interface
29
+ with gr.Blocks() as demo:
30
+ # Log each interaction
31
+ def on_text_input(text):
32
+ print(f"User typed text: {text}")
33
+
34
+ def on_temperature_change(val):
35
+ print(f"Temperature slider adjusted to: {val}")
36
+
37
+ def on_repetition_penalty_change(val):
38
+ print(f"Repetition Penalty slider adjusted to: {val}")
39
+
40
+ def on_max_length_change(val):
41
+ print(f"Max Length slider adjusted to: {val}")
42
+
43
+ # Text input
44
+ text_input = gr.Textbox(lines=2, placeholder="Enter text to convert to speech", label="Text")
45
+ text_input.change(on_text_input, inputs=text_input)
46
+
47
+ # Sliders with change events for tracking
48
+ temperature_slider = gr.Slider(0.1, 1.0, value=0.1, label="Temperature")
49
+ temperature_slider.change(on_temperature_change, inputs=temperature_slider)
50
+
51
+ repetition_penalty_slider = gr.Slider(1.0, 2.0, value=1.1, label="Repetition Penalty")
52
+ repetition_penalty_slider.change(on_repetition_penalty_change, inputs=repetition_penalty_slider)
53
+
54
+ max_length_slider = gr.Slider(512, 4096, value=4096, step=256, label="Max Length")
55
+ max_length_slider.change(on_max_length_change, inputs=max_length_slider)
56
+
57
+ # Button to generate TTS and Audio output
58
+ generate_button = gr.Button("Generate Speech")
59
+ audio_output = gr.Audio(type="filepath", label="Generated Speech")
60
+
61
+ # Define interaction between input and output
62
+ generate_button.click(
63
+ generate_tts,
64
+ inputs=[text_input, temperature_slider, repetition_penalty_slider, max_length_slider],
65
+ outputs=audio_output
66
+ )
67
+
68
  print("Launching Gradio interface...")
69
  demo.launch()