Spaces:
Sleeping
Sleeping
vidhishiste
commited on
Commit
•
6ce4f53
1
Parent(s):
6de6f8e
dark theme
Browse files
app.py
CHANGED
@@ -1,78 +1,78 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
4 |
-
|
5 |
|
6 |
-
|
7 |
-
|
8 |
|
9 |
-
|
10 |
|
11 |
-
#
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
|
19 |
-
#
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
|
24 |
-
#
|
25 |
-
|
26 |
-
#
|
27 |
-
|
28 |
-
|
29 |
|
30 |
-
#
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
|
40 |
-
#
|
41 |
# interface.launch()
|
42 |
-
import gradio as gr
|
43 |
-
from speech_recognition import Recognizer, Microphone
|
44 |
|
45 |
-
# Initialize speech recognizer
|
46 |
-
recognizer = Recognizer()
|
47 |
|
48 |
-
def speech_to_text(input_text=None):
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
|
65 |
-
|
66 |
|
67 |
-
# Create Gradio interface
|
68 |
-
iface = gr.Interface(
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
)
|
75 |
|
76 |
-
# Launch the interface
|
77 |
-
iface.launch()
|
78 |
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
def greet(name):
|
4 |
+
return "Hello " + name + "!!"
|
5 |
|
6 |
+
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
7 |
+
iface.launch()
|
8 |
|
9 |
+
from gradio import Interface, Textbox, Button, css
|
10 |
|
11 |
+
# Define the theme
|
12 |
+
theme = css.Theme(
|
13 |
+
background="#212529",
|
14 |
+
text_color="#f8f9fa",
|
15 |
+
button_color="#4285f4",
|
16 |
+
button_text_color="#ffffff",
|
17 |
+
)
|
18 |
|
19 |
+
# Define the UI components
|
20 |
+
input_box = Textbox(label="Input:", placeholder="Enter your text here...", theme=theme)
|
21 |
+
submit_button = Button("Submit", theme=theme)
|
22 |
+
output_box = Textbox(label="Output:", theme=theme)
|
23 |
|
24 |
+
# Define the function to handle the input
|
25 |
+
def handle_input(text):
|
26 |
+
# Replace this with your actual processing logic
|
27 |
+
output_text = f"Processed input: {text}"
|
28 |
+
return output_text
|
29 |
|
30 |
+
# Create the interface
|
31 |
+
interface = Interface(
|
32 |
+
fn=handle_input,
|
33 |
+
inputs=[input_box, submit_button],
|
34 |
+
outputs=[output_box],
|
35 |
+
layout="horizontal",
|
36 |
+
title="Dark Theme UI",
|
37 |
+
theme=theme,
|
38 |
+
)
|
39 |
|
40 |
+
# Launch the interface
|
41 |
# interface.launch()
|
42 |
+
# import gradio as gr
|
43 |
+
# from speech_recognition import Recognizer, Microphone
|
44 |
|
45 |
+
# # Initialize speech recognizer
|
46 |
+
# recognizer = Recognizer()
|
47 |
|
48 |
+
# def speech_to_text(input_text=None):
|
49 |
+
# """
|
50 |
+
# Speech to text function
|
51 |
+
# """
|
52 |
+
# # Record audio
|
53 |
+
# with Microphone() as source:
|
54 |
+
# recognizer.adjust_for_ambient_noise(source)
|
55 |
+
# audio = recognizer.listen(source)
|
56 |
|
57 |
+
# # Recognize speech
|
58 |
+
# try:
|
59 |
+
# text = recognizer.recognize_google(audio)
|
60 |
+
# output_text = f"You said: {text}"
|
61 |
+
# except Exception as e:
|
62 |
+
# print(e)
|
63 |
+
# output_text = "Could not understand your speech. Please try again!"
|
64 |
|
65 |
+
# return output_text
|
66 |
|
67 |
+
# # Create Gradio interface
|
68 |
+
# iface = gr.Interface(
|
69 |
+
# fn=speech_to_text,
|
70 |
+
# inputs=[],
|
71 |
+
# outputs=gr.Textbox(label="Transcription"),
|
72 |
+
# title="Speech to Text",
|
73 |
+
# theme="dark",
|
74 |
+
# )
|
75 |
|
76 |
+
# # Launch the interface
|
77 |
+
# iface.launch()
|
78 |
|