Spaces:
Runtime error
Runtime error
save
Browse files
app.py
CHANGED
@@ -4,7 +4,6 @@ import gradio as gr
|
|
4 |
import whisper
|
5 |
from flask import Flask, jsonify, request
|
6 |
import requests
|
7 |
-
import numpy as np
|
8 |
import streamlit as st
|
9 |
|
10 |
|
@@ -20,7 +19,7 @@ def indexApi():
|
|
20 |
def runApi():
|
21 |
audio_url = request.form.get("audio_url")
|
22 |
# key = request.form.get("key")
|
23 |
-
|
24 |
print(audio_url)
|
25 |
|
26 |
if (modelSelection == None):
|
@@ -77,179 +76,3 @@ if __name__ == "__main__":
|
|
77 |
# return result.text, gr.update(visible=True), gr.update(visible=True), gr.update(visible=True)
|
78 |
|
79 |
|
80 |
-
|
81 |
-
|
82 |
-
# css = """
|
83 |
-
# .gradio-container {
|
84 |
-
# font-family: 'IBM Plex Sans', sans-serif;
|
85 |
-
# }
|
86 |
-
# .gr-button {
|
87 |
-
# color: white;
|
88 |
-
# border-color: black;
|
89 |
-
# background: black;
|
90 |
-
# }
|
91 |
-
# input[type='range'] {
|
92 |
-
# accent-color: black;
|
93 |
-
# }
|
94 |
-
# .dark input[type='range'] {
|
95 |
-
# accent-color: #dfdfdf;
|
96 |
-
# }
|
97 |
-
# .container {
|
98 |
-
# max-width: 730px;
|
99 |
-
# margin: auto;
|
100 |
-
# padding-top: 1.5rem;
|
101 |
-
# }
|
102 |
-
|
103 |
-
# .details:hover {
|
104 |
-
# text-decoration: underline;
|
105 |
-
# }
|
106 |
-
# .gr-button {
|
107 |
-
# white-space: nowrap;
|
108 |
-
# }
|
109 |
-
# .gr-button:focus {
|
110 |
-
# border-color: rgb(147 197 253 / var(--tw-border-opacity));
|
111 |
-
# outline: none;
|
112 |
-
# box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
|
113 |
-
# --tw-border-opacity: 1;
|
114 |
-
# --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
|
115 |
-
# --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(3px var(--tw-ring-offset-width)) var(--tw-ring-color);
|
116 |
-
# --tw-ring-color: rgb(191 219 254 / var(--tw-ring-opacity));
|
117 |
-
# --tw-ring-opacity: .5;
|
118 |
-
# }
|
119 |
-
# .footer {
|
120 |
-
# margin-bottom: 45px;
|
121 |
-
# margin-top: 35px;
|
122 |
-
# text-align: center;
|
123 |
-
# border-bottom: 1px solid #e5e5e5;
|
124 |
-
# }
|
125 |
-
# .footer>p {
|
126 |
-
# font-size: .8rem;
|
127 |
-
# display: inline-block;
|
128 |
-
# padding: 0 10px;
|
129 |
-
# transform: translateY(10px);
|
130 |
-
# background: white;
|
131 |
-
# }
|
132 |
-
# .dark .footer {
|
133 |
-
# border-color: #303030;
|
134 |
-
# }
|
135 |
-
# .dark .footer>p {
|
136 |
-
# background: #0b0f19;
|
137 |
-
# }
|
138 |
-
# .prompt h4{
|
139 |
-
# margin: 1.25em 0 .25em 0;
|
140 |
-
# font-weight: bold;
|
141 |
-
# font-size: 115%;
|
142 |
-
# }
|
143 |
-
# .animate-spin {
|
144 |
-
# animation: spin 1s linear infinite;
|
145 |
-
# }
|
146 |
-
# @keyframes spin {
|
147 |
-
# from {
|
148 |
-
# transform: rotate(0deg);
|
149 |
-
# }
|
150 |
-
# to {
|
151 |
-
# transform: rotate(360deg);
|
152 |
-
# }
|
153 |
-
# }
|
154 |
-
# #share-btn-container {
|
155 |
-
# display: flex; margin-top: 1.5rem !important; padding-left: 0.5rem !important; padding-right: 0.5rem !important; background-color: #000000; justify-content: center; align-items: center; border-radius: 9999px !important; width: 13rem;
|
156 |
-
# }
|
157 |
-
# #share-btn {
|
158 |
-
# all: initial; color: #ffffff;font-weight: 600; cursor:pointer; font-family: 'IBM Plex Sans', sans-serif; margin-left: 0.5rem !important; padding-top: 0.25rem !important; padding-bottom: 0.25rem !important;
|
159 |
-
# }
|
160 |
-
# #share-btn * {
|
161 |
-
# all: unset;
|
162 |
-
# }
|
163 |
-
# """
|
164 |
-
|
165 |
-
# block = gr.Blocks(css=css)
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
# with block:
|
170 |
-
# gr.HTML(
|
171 |
-
# """
|
172 |
-
# <div style="text-align: center; max-width: 650px; margin: 0 auto;">
|
173 |
-
# <div
|
174 |
-
# style="
|
175 |
-
# display: inline-flex;
|
176 |
-
# align-items: center;
|
177 |
-
# gap: 0.8rem;
|
178 |
-
# font-size: 1.75rem;
|
179 |
-
# "
|
180 |
-
# >
|
181 |
-
# <svg
|
182 |
-
# width="0.65em"
|
183 |
-
# height="0.65em"
|
184 |
-
# viewBox="0 0 115 115"
|
185 |
-
# fill="none"
|
186 |
-
# xmlns="http://www.w3.org/2000/svg"
|
187 |
-
# >
|
188 |
-
# <rect width="23" height="23" fill="white"></rect>
|
189 |
-
# <rect y="69" width="23" height="23" fill="white"></rect>
|
190 |
-
# <rect x="23" width="23" height="23" fill="#AEAEAE"></rect>
|
191 |
-
# <rect x="23" y="69" width="23" height="23" fill="#AEAEAE"></rect>
|
192 |
-
# <rect x="46" width="23" height="23" fill="white"></rect>
|
193 |
-
# <rect x="46" y="69" width="23" height="23" fill="white"></rect>
|
194 |
-
# <rect x="69" width="23" height="23" fill="black"></rect>
|
195 |
-
# <rect x="69" y="69" width="23" height="23" fill="black"></rect>
|
196 |
-
# <rect x="92" width="23" height="23" fill="#D9D9D9"></rect>
|
197 |
-
# <rect x="92" y="69" width="23" height="23" fill="#AEAEAE"></rect>
|
198 |
-
# <rect x="115" y="46" width="23" height="23" fill="white"></rect>
|
199 |
-
# <rect x="115" y="115" width="23" height="23" fill="white"></rect>
|
200 |
-
# <rect x="115" y="69" width="23" height="23" fill="#D9D9D9"></rect>
|
201 |
-
# <rect x="92" y="46" width="23" height="23" fill="#AEAEAE"></rect>
|
202 |
-
# <rect x="92" y="115" width="23" height="23" fill="#AEAEAE"></rect>
|
203 |
-
# <rect x="92" y="69" width="23" height="23" fill="white"></rect>
|
204 |
-
# <rect x="69" y="46" width="23" height="23" fill="white"></rect>
|
205 |
-
# <rect x="69" y="115" width="23" height="23" fill="white"></rect>
|
206 |
-
# <rect x="69" y="69" width="23" height="23" fill="#D9D9D9"></rect>
|
207 |
-
# <rect x="46" y="46" width="23" height="23" fill="black"></rect>
|
208 |
-
# <rect x="46" y="115" width="23" height="23" fill="black"></rect>
|
209 |
-
# <rect x="46" y="69" width="23" height="23" fill="black"></rect>
|
210 |
-
# <rect x="23" y="46" width="23" height="23" fill="#D9D9D9"></rect>
|
211 |
-
# <rect x="23" y="115" width="23" height="23" fill="#AEAEAE"></rect>
|
212 |
-
# <rect x="23" y="69" width="23" height="23" fill="black"></rect>
|
213 |
-
# </svg>
|
214 |
-
# <h1 style="font-weight: 900; margin-bottom: 7px;">
|
215 |
-
# Whisper
|
216 |
-
# </h1>
|
217 |
-
# </div>
|
218 |
-
# <p style="margin-bottom: 10px; font-size: 94%">
|
219 |
-
# Whisper is a general-purpose speech recognition model. It is trained on a large dataset of diverse audio and is also a multi-task model that can perform multilingual speech recognition as well as speech translation and language identification. This demo cuts audio after around 30 secs.
|
220 |
-
# </p>
|
221 |
-
# <p>You can skip the queue by using google colab for the space: <a href="https://colab.research.google.com/drive/1WJ98KHgZxFGrHiMm4TyWZllSew_Af_ff?usp=sharing"><img data-canonical-src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab" src="https://camo.githubusercontent.com/84f0493939e0c4de4e6dbe113251b4bfb5353e57134ffd9fcab6b8714514d4d1/68747470733a2f2f636f6c61622e72657365617263682e676f6f676c652e636f6d2f6173736574732f636f6c61622d62616467652e737667"></a></p>
|
222 |
-
# </div>
|
223 |
-
# """
|
224 |
-
# )
|
225 |
-
# with gr.Group():
|
226 |
-
# with gr.Box():
|
227 |
-
# with gr.Row().style(mobile_collapse=False, equal_height=True):
|
228 |
-
# audio = gr.Audio(
|
229 |
-
# label="Input Audio",
|
230 |
-
# show_label=False,
|
231 |
-
# source="microphone",
|
232 |
-
# type="filepath"
|
233 |
-
# )
|
234 |
-
|
235 |
-
# btn = gr.Button("Transcribe")
|
236 |
-
# text = gr.Textbox(show_label=False, elem_id="result-textarea")
|
237 |
-
# with gr.Group(elem_id="share-btn-container"):
|
238 |
-
# community_icon = gr.HTML(community_icon_html, visible=False)
|
239 |
-
# loading_icon = gr.HTML(loading_icon_html, visible=False)
|
240 |
-
# share_button = gr.Button("Share to community", elem_id="share-btn", visible=False)
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
# btn.click(inference, inputs=[audio], outputs=[text, community_icon, loading_icon, share_button])
|
246 |
-
# share_button.click(None, [], [], _js=share_js)
|
247 |
-
|
248 |
-
# gr.HTML('''
|
249 |
-
# <div class="footer">
|
250 |
-
# <p>Model by <a href="https://github.com/openai/whisper" style="text-decoration: underline;" target="_blank">OpenAI</a> - Gradio Demo by 🤗 Hugging Face
|
251 |
-
# </p>
|
252 |
-
# </div>
|
253 |
-
# ''')
|
254 |
-
|
255 |
-
# block.launch()
|
|
|
4 |
import whisper
|
5 |
from flask import Flask, jsonify, request
|
6 |
import requests
|
|
|
7 |
import streamlit as st
|
8 |
|
9 |
|
|
|
19 |
def runApi():
|
20 |
audio_url = request.form.get("audio_url")
|
21 |
# key = request.form.get("key")
|
22 |
+
modelSelection = request.form.get("model")
|
23 |
print(audio_url)
|
24 |
|
25 |
if (modelSelection == None):
|
|
|
76 |
# return result.text, gr.update(visible=True), gr.update(visible=True), gr.update(visible=True)
|
77 |
|
78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|