Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
# List of names and voices
|
| 4 |
+
names = ["Alice", "Bob", "Charlie"]
|
| 5 |
+
voices = ["Voice1", "Voice2", "Voice3"]
|
| 6 |
+
|
| 7 |
+
# Function to display selected voice for each name
|
| 8 |
+
def display_voice(*args):
|
| 9 |
+
results = []
|
| 10 |
+
for name, selected_voice in zip(names, args):
|
| 11 |
+
results.append(f"For {name}: selected voice {selected_voice}")
|
| 12 |
+
return "\n".join(results)
|
| 13 |
+
|
| 14 |
+
# Creating Gradio interface
|
| 15 |
+
def create_interface():
|
| 16 |
+
inputs = []
|
| 17 |
+
for name in names:
|
| 18 |
+
dropdown = gr.Dropdown(choices=voices, label=f"Select voice for {name}")
|
| 19 |
+
inputs.append(dropdown)
|
| 20 |
+
|
| 21 |
+
interface = gr.Interface(
|
| 22 |
+
fn=display_voice,
|
| 23 |
+
inputs=inputs,
|
| 24 |
+
outputs="text",
|
| 25 |
+
live=True
|
| 26 |
+
)
|
| 27 |
+
return interface
|
| 28 |
+
|
| 29 |
+
app = create_interface()
|
| 30 |
+
|
| 31 |
+
if __name__ == "__main__":
|
| 32 |
+
app.launch()
|