Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
# Load the model
|
4 |
+
interface = gr.load("models/fastinom/ASR_fassy")
|
5 |
+
|
6 |
+
# Customize the Gradio interface with additional styles and layout
|
7 |
+
css = """
|
8 |
+
body {
|
9 |
+
background-color: #f5f5f5;
|
10 |
+
font-family: 'Arial', sans-serif;
|
11 |
+
}
|
12 |
+
.container {
|
13 |
+
max-width: 800px;
|
14 |
+
margin: auto;
|
15 |
+
padding: 20px;
|
16 |
+
background-color: #ffffff;
|
17 |
+
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
|
18 |
+
border-radius: 10px;
|
19 |
+
}
|
20 |
+
h1 {
|
21 |
+
text-align: center;
|
22 |
+
color: #333;
|
23 |
+
}
|
24 |
+
.audio-container {
|
25 |
+
display: flex;
|
26 |
+
justify-content: center;
|
27 |
+
margin-top: 20px;
|
28 |
+
}
|
29 |
+
.output-container {
|
30 |
+
margin-top: 20px;
|
31 |
+
}
|
32 |
+
.button-container {
|
33 |
+
display: flex;
|
34 |
+
justify-content: center;
|
35 |
+
margin-top: 20px;
|
36 |
+
}
|
37 |
+
"""
|
38 |
+
|
39 |
+
# Define the function to use the loaded model
|
40 |
+
def custom_interface(audio):
|
41 |
+
return interface(audio)
|
42 |
+
|
43 |
+
# Define the Gradio Blocks layout
|
44 |
+
with gr.Blocks(css=css) as demo:
|
45 |
+
gr.Markdown("# Shona Speech-to-Text App", elem_classes="container")
|
46 |
+
|
47 |
+
with gr.Row(elem_classes="container"):
|
48 |
+
gr.Markdown("### Record your voice in Shona and get the transcription:")
|
49 |
+
|
50 |
+
audio = gr.Audio(type="filepath", label="Record Your Voice", elem_classes="audio-container")
|
51 |
+
transcription = gr.Textbox(label="Transcription", placeholder="Transcription will appear here...", elem_classes="output-container")
|
52 |
+
|
53 |
+
with gr.Row(elem_classes="button-container"):
|
54 |
+
submit_btn = gr.Button("Submit")
|
55 |
+
|
56 |
+
# Connect the submit button to the custom interface function
|
57 |
+
submit_btn.click(custom_interface, inputs=audio, outputs=transcription)
|
58 |
+
|
59 |
+
# Launch the interface
|
60 |
+
demo.launch()
|