hivecorp commited on
Commit
f3bc85b
·
verified ·
1 Parent(s): 465302a

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -0
app.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import os
3
+
4
+ # Define available voices
5
+ voices = [
6
+ {"name": "Jessica", "gender": "Female", "country": "US", "file": "jessica.mp3"},
7
+ {"name": "Michael", "gender": "Male", "country": "UK", "file": "michael.mp3"},
8
+ {"name": "Sophia", "gender": "Female", "country": "Canada", "file": "sophia.mp3"},
9
+ {"name": "David", "gender": "Male", "country": "Australia", "file": "david.mp3"},
10
+ {"name": "Emma", "gender": "Female", "country": "Germany", "file": "emma.mp3"},
11
+ {"name": "Lucas", "gender": "Male", "country": "France", "file": "lucas.mp3"},
12
+ {"name": "Liam", "gender": "Male", "country": "India", "file": "liam.mp3"},
13
+ {"name": "Olivia", "gender": "Female", "country": "Brazil", "file": "olivia.mp3"},
14
+ {"name": "Noah", "gender": "Male", "country": "Japan", "file": "noah.mp3"},
15
+ {"name": "Ava", "gender": "Female", "country": "South Korea", "file": "ava.mp3"},
16
+ {"name": "Isabella", "gender": "Female", "country": "Italy", "file": "isabella.mp3"},
17
+ {"name": "Ethan", "gender": "Male", "country": "Spain", "file": "ethan.mp3"},
18
+ {"name": "Mason", "gender": "Male", "country": "Netherlands", "file": "mason.mp3"},
19
+ {"name": "Mia", "gender": "Female", "country": "Russia", "file": "mia.mp3"},
20
+ {"name": "Charlotte", "gender": "Female", "country": "China", "file": "charlotte.mp3"},
21
+ ]
22
+
23
+ # Function to return audio file path
24
+ def play_audio(file):
25
+ return f"voices/{file}"
26
+
27
+ # Create layout
28
+ with gr.Blocks() as demo:
29
+ gr.Markdown("<h2 style='text-align: center;'>Human Like Voice on Pro Plan</h2>")
30
+
31
+ # Grid layout (3 columns, 5 rows)
32
+ for i in range(0, len(voices), 3):
33
+ with gr.Row():
34
+ for j in range(3):
35
+ if i + j < len(voices):
36
+ voice = voices[i + j]
37
+ with gr.Column():
38
+ audio = gr.Audio(play_audio(voice["file"]), autoplay=False, elem_id=voice["name"])
39
+ btn = gr.Button(f"▶ Play {voice['name']}")
40
+ info = gr.Markdown(f"**{voice['name']}**<br>{voice['gender']} | {voice['country']}")
41
+ btn.click(fn=play_audio, inputs=[], outputs=[audio])
42
+
43
+ # Launch the app
44
+ demo.launch()