Update src/interface.py
Browse files- src/interface.py +50 -55
src/interface.py
CHANGED
@@ -7,12 +7,7 @@ SYNTHESIS_MODES = {
|
|
7 |
"styles": ["Technical", "Narrative", "Instructional", "Descriptive"],
|
8 |
"default_temp": 0.7,
|
9 |
"default_chunks": 300,
|
10 |
-
"system_prompt": """Convert this content into clear narration.
|
11 |
-
Format:
|
12 |
-
- Clear sentence structures
|
13 |
-
- Natural pauses (...)
|
14 |
-
- Term definitions when needed
|
15 |
-
- Proper transitions"""
|
16 |
},
|
17 |
"podcast": {
|
18 |
"description": "Conversational style with engaging tone and dynamic pacing",
|
@@ -67,42 +62,42 @@ def create_interface():
|
|
67 |
|
68 |
synthesis_mode = gr.State(SYNTHESIS_MODES["narration"])
|
69 |
|
70 |
-
# Main
|
71 |
with gr.Row():
|
72 |
-
#
|
73 |
-
with gr.Column(
|
74 |
-
with gr.
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
)
|
81 |
-
|
82 |
-
|
83 |
-
file_types=[".pdf"],
|
84 |
-
scale=1
|
85 |
)
|
86 |
|
87 |
-
|
88 |
-
with gr.Column(scale=1):
|
89 |
-
mode_select = gr.Radio(
|
90 |
-
choices=list(SYNTHESIS_MODES.keys()),
|
91 |
-
value="narration",
|
92 |
-
label="🎭 Output Mode",
|
93 |
-
info="Select output type"
|
94 |
-
)
|
95 |
-
mode_description = gr.Markdown(
|
96 |
-
SYNTHESIS_MODES["narration"]["description"],
|
97 |
-
elem_classes=["mode-description"]
|
98 |
-
)
|
99 |
-
|
100 |
-
# Parameters Row
|
101 |
with gr.Row():
|
102 |
-
# Voice
|
103 |
with gr.Column():
|
104 |
-
with gr.
|
105 |
-
gr.Markdown("### 🎛️ Voice & Style")
|
106 |
voice_select = gr.Radio(
|
107 |
choices=["alloy", "echo", "fable", "onyx", "nova", "shimmer"],
|
108 |
value="onyx",
|
@@ -116,10 +111,9 @@ def create_interface():
|
|
116 |
interactive=True
|
117 |
)
|
118 |
|
119 |
-
# Processing
|
120 |
with gr.Column():
|
121 |
-
with gr.
|
122 |
-
gr.Markdown("### ⚙️ Processing")
|
123 |
with gr.Row():
|
124 |
chunk_size = gr.Slider(
|
125 |
minimum=100, maximum=1000,
|
@@ -145,29 +139,30 @@ def create_interface():
|
|
145 |
process_btn = gr.Button("🚀 Generate Audio", variant="primary", scale=2)
|
146 |
status_output = gr.Textbox(label="📋 Status", scale=1)
|
147 |
|
148 |
-
# Output
|
149 |
with gr.Tabs():
|
150 |
-
with gr.
|
151 |
output_table = gr.Dataframe(
|
152 |
headers=["🔍 Segment", "📄 Content", "🎭 Script"],
|
153 |
wrap=True
|
154 |
)
|
155 |
-
with gr.
|
156 |
with gr.Row():
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
|
|
|
|
169 |
|
170 |
-
# Footer
|
171 |
gr.HTML(
|
172 |
"""
|
173 |
<div style="text-align: center; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid #ccc;">
|
|
|
7 |
"styles": ["Technical", "Narrative", "Instructional", "Descriptive"],
|
8 |
"default_temp": 0.7,
|
9 |
"default_chunks": 300,
|
10 |
+
"system_prompt": """Convert this content into clear narration."""
|
|
|
|
|
|
|
|
|
|
|
11 |
},
|
12 |
"podcast": {
|
13 |
"description": "Conversational style with engaging tone and dynamic pacing",
|
|
|
62 |
|
63 |
synthesis_mode = gr.State(SYNTHESIS_MODES["narration"])
|
64 |
|
65 |
+
# Main Settings Row
|
66 |
with gr.Row():
|
67 |
+
# Core Settings Column
|
68 |
+
with gr.Column():
|
69 |
+
with gr.Accordion("🔑 Core Settings", open=True):
|
70 |
+
with gr.Row():
|
71 |
+
api_key = gr.Textbox(
|
72 |
+
label="OpenAI API Key",
|
73 |
+
placeholder="sk-...",
|
74 |
+
type="password",
|
75 |
+
scale=2
|
76 |
+
)
|
77 |
+
file_input = gr.File(
|
78 |
+
label="PDF Document",
|
79 |
+
file_types=[".pdf"],
|
80 |
+
scale=1
|
81 |
+
)
|
82 |
+
|
83 |
+
# Mode Selection Column
|
84 |
+
with gr.Column():
|
85 |
+
with gr.Accordion("🎭 Output Mode", open=True):
|
86 |
+
mode_select = gr.Radio(
|
87 |
+
choices=list(SYNTHESIS_MODES.keys()),
|
88 |
+
value="narration",
|
89 |
+
label="Select Mode",
|
90 |
+
info="Choose output style"
|
91 |
)
|
92 |
+
mode_description = gr.Markdown(
|
93 |
+
SYNTHESIS_MODES["narration"]["description"]
|
|
|
|
|
94 |
)
|
95 |
|
96 |
+
# Voice and Processing Settings Row
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
with gr.Row():
|
98 |
+
# Voice Settings Column
|
99 |
with gr.Column():
|
100 |
+
with gr.Accordion("🎛️ Voice & Style", open=True):
|
|
|
101 |
voice_select = gr.Radio(
|
102 |
choices=["alloy", "echo", "fable", "onyx", "nova", "shimmer"],
|
103 |
value="onyx",
|
|
|
111 |
interactive=True
|
112 |
)
|
113 |
|
114 |
+
# Processing Settings Column
|
115 |
with gr.Column():
|
116 |
+
with gr.Accordion("⚙️ Processing Parameters", open=True):
|
|
|
117 |
with gr.Row():
|
118 |
chunk_size = gr.Slider(
|
119 |
minimum=100, maximum=1000,
|
|
|
139 |
process_btn = gr.Button("🚀 Generate Audio", variant="primary", scale=2)
|
140 |
status_output = gr.Textbox(label="📋 Status", scale=1)
|
141 |
|
142 |
+
# Output Section
|
143 |
with gr.Tabs():
|
144 |
+
with gr.TabItem("📝 Content"):
|
145 |
output_table = gr.Dataframe(
|
146 |
headers=["🔍 Segment", "📄 Content", "🎭 Script"],
|
147 |
wrap=True
|
148 |
)
|
149 |
+
with gr.TabItem("🎧 Audio"):
|
150 |
with gr.Row():
|
151 |
+
with gr.Column(scale=2):
|
152 |
+
audio_output = gr.Audio(
|
153 |
+
label="🔊 Synthesized Audio",
|
154 |
+
type="filepath",
|
155 |
+
show_download_button=True
|
156 |
+
)
|
157 |
+
with gr.Column(scale=1):
|
158 |
+
with gr.Accordion("📚 Quick Tips", open=True):
|
159 |
+
gr.Markdown("""
|
160 |
+
- 🎯 Lower temperature = more consistent
|
161 |
+
- 📏 Smaller chunks = more precise
|
162 |
+
- 🎙️ Try different voices for best fit
|
163 |
+
- 💫 Match style to content type
|
164 |
+
""")
|
165 |
|
|
|
166 |
gr.HTML(
|
167 |
"""
|
168 |
<div style="text-align: center; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid #ccc;">
|