Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -70,100 +70,7 @@ def transcribe_audio(audio_file, destination_language):
|
|
70 |
return f"Error during transcription: {str(e)}"
|
71 |
|
72 |
# Gradio interface
|
73 |
-
with gr.Blocks(
|
74 |
-
body {
|
75 |
-
background: #f2f2f2; /* Light background for visibility */
|
76 |
-
font-family: 'Arial', sans-serif; /* Easy-to-read font */
|
77 |
-
color: #333333; /* Dark text color for good contrast */
|
78 |
-
display: flex;
|
79 |
-
justify-content: center;
|
80 |
-
align-items: center;
|
81 |
-
height: 100vh;
|
82 |
-
margin: 0;
|
83 |
-
padding: 0;
|
84 |
-
}
|
85 |
-
h1, h2, h3, label {
|
86 |
-
color: #4A90E2; /* Primary blue for headers */
|
87 |
-
text-align: center;
|
88 |
-
font-size: 26px; /* Increased font size */
|
89 |
-
font-weight: bold; /* Bold text */
|
90 |
-
}
|
91 |
-
button {
|
92 |
-
background-color: #1E3C72; /* Professional dark blue */
|
93 |
-
color: white;
|
94 |
-
border: none;
|
95 |
-
border-radius: 8px;
|
96 |
-
padding: 14px 24px; /* Larger buttons */
|
97 |
-
font-size: 20px; /* Increased font size */
|
98 |
-
cursor: pointer;
|
99 |
-
transition: all 0.3s ease;
|
100 |
-
}
|
101 |
-
button:hover {
|
102 |
-
background-color: #1C2A48; /* Darker blue on hover */
|
103 |
-
}
|
104 |
-
input, textarea, select {
|
105 |
-
background-color: #ffffff;
|
106 |
-
color: #333333;
|
107 |
-
border: 2px solid #4A90E2; /* Border color */
|
108 |
-
border-radius: 8px;
|
109 |
-
padding: 14px; /* Larger padding */
|
110 |
-
width: 100%;
|
111 |
-
font-size: 18px; /* Increased font size */
|
112 |
-
margin-bottom: 20px; /* Space between input elements */
|
113 |
-
}
|
114 |
-
input:focus, textarea:focus, select:focus {
|
115 |
-
border-color: #FF5722; /* Highlight on focus */
|
116 |
-
}
|
117 |
-
.chat-container {
|
118 |
-
background: rgba(0, 0, 0, 0.6);
|
119 |
-
padding: 30px;
|
120 |
-
border-radius: 15px;
|
121 |
-
max-width: 600px;
|
122 |
-
width: 100%;
|
123 |
-
box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
|
124 |
-
display: flex;
|
125 |
-
flex-direction: column;
|
126 |
-
}
|
127 |
-
.message {
|
128 |
-
background: #2A3E72;
|
129 |
-
padding: 16px 20px;
|
130 |
-
border-radius: 15px;
|
131 |
-
margin: 10px 0;
|
132 |
-
max-width: 80%;
|
133 |
-
word-wrap: break-word;
|
134 |
-
color: #ffffff;
|
135 |
-
}
|
136 |
-
.message.user {
|
137 |
-
background: #3A4F88;
|
138 |
-
align-self: flex-end;
|
139 |
-
}
|
140 |
-
.message.bot {
|
141 |
-
background: #1E3C72;
|
142 |
-
}
|
143 |
-
#audio-file-container {
|
144 |
-
background-color: transparent; /* No background color for the audio container */
|
145 |
-
padding: 0;
|
146 |
-
border: none; /* No border */
|
147 |
-
}
|
148 |
-
#upload-audio-label {
|
149 |
-
font-weight: normal; /* Remove bold text for the label */
|
150 |
-
color: #333333; /* Keep the text color neutral */
|
151 |
-
}
|
152 |
-
#upload-audio-file {
|
153 |
-
font-size: 14px; /* Smaller size for the upload button */
|
154 |
-
padding: 8px 16px; /* Reduced padding for a smaller button */
|
155 |
-
}
|
156 |
-
.tabs .tab-title {
|
157 |
-
color: #333333;
|
158 |
-
font-weight: bold;
|
159 |
-
}
|
160 |
-
.tab-content {
|
161 |
-
background-color: #ffffff; /* White background for the audio translation tab */
|
162 |
-
padding: 20px;
|
163 |
-
border-radius: 10px;
|
164 |
-
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
|
165 |
-
}
|
166 |
-
""") as demo:
|
167 |
with gr.Row():
|
168 |
gr.Markdown(
|
169 |
"""
|
@@ -186,19 +93,18 @@ input:focus, textarea:focus, select:focus {
|
|
186 |
)
|
187 |
|
188 |
with gr.Tab("Audio Translation"):
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
audio_translate_button = gr.Button("Transcribe and Translate")
|
196 |
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
|
203 |
if __name__ == "__main__":
|
204 |
demo.launch()
|
|
|
70 |
return f"Error during transcription: {str(e)}"
|
71 |
|
72 |
# Gradio interface
|
73 |
+
with gr.Blocks() as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
with gr.Row():
|
75 |
gr.Markdown(
|
76 |
"""
|
|
|
93 |
)
|
94 |
|
95 |
with gr.Tab("Audio Translation"):
|
96 |
+
audio_input = gr.Audio(label="Upload Audio File", type="filepath")
|
97 |
+
audio_language_dropdown = gr.Dropdown(
|
98 |
+
choices=available_languages, label="Select Destination Language"
|
99 |
+
)
|
100 |
+
audio_translated_text_output = gr.Textbox(label="Transcribed and Translated Text", lines=4)
|
101 |
+
audio_translate_button = gr.Button("Transcribe and Translate")
|
|
|
102 |
|
103 |
+
audio_translate_button.click(
|
104 |
+
transcribe_audio,
|
105 |
+
inputs=[audio_input, audio_language_dropdown],
|
106 |
+
outputs=[audio_translated_text_output],
|
107 |
+
)
|
108 |
|
109 |
if __name__ == "__main__":
|
110 |
demo.launch()
|