jbilcke-hf HF staff commited on
Commit
2e0561d
1 Parent(s): fc7482c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -134
app.py CHANGED
@@ -18,144 +18,13 @@ def inference(audio):
18
  result = whisper.decode(model, mel, options)
19
 
20
  print(result.text)
21
- return result.text, gr.update(visible=True)
22
 
23
 
24
-
25
-
26
- css = """
27
- .gradio-container {
28
- font-family: 'IBM Plex Sans', sans-serif;
29
- }
30
- .gr-button {
31
- color: white;
32
- border-color: black;
33
- background: black;
34
- }
35
- input[type='range'] {
36
- accent-color: black;
37
- }
38
- .dark input[type='range'] {
39
- accent-color: #dfdfdf;
40
- }
41
- .container {
42
- max-width: 730px;
43
- margin: auto;
44
- padding-top: 1.5rem;
45
- }
46
-
47
- .details:hover {
48
- text-decoration: underline;
49
- }
50
- .gr-button {
51
- white-space: nowrap;
52
- }
53
- .gr-button:focus {
54
- border-color: rgb(147 197 253 / var(--tw-border-opacity));
55
- outline: none;
56
- box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
57
- --tw-border-opacity: 1;
58
- --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
59
- --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(3px var(--tw-ring-offset-width)) var(--tw-ring-color);
60
- --tw-ring-color: rgb(191 219 254 / var(--tw-ring-opacity));
61
- --tw-ring-opacity: .5;
62
- }
63
- .footer {
64
- margin-bottom: 45px;
65
- margin-top: 35px;
66
- text-align: center;
67
- border-bottom: 1px solid #e5e5e5;
68
- }
69
- .footer>p {
70
- font-size: .8rem;
71
- display: inline-block;
72
- padding: 0 10px;
73
- transform: translateY(10px);
74
- background: white;
75
- }
76
- .dark .footer {
77
- border-color: #303030;
78
- }
79
- .dark .footer>p {
80
- background: #0b0f19;
81
- }
82
- .prompt h4{
83
- margin: 1.25em 0 .25em 0;
84
- font-weight: bold;
85
- font-size: 115%;
86
- }
87
- .animate-spin {
88
- animation: spin 1s linear infinite;
89
- }
90
- @keyframes spin {
91
- from {
92
- transform: rotate(0deg);
93
- }
94
- to {
95
- transform: rotate(360deg);
96
- }
97
- }
98
- """
99
-
100
  block = gr.Blocks(css=css)
101
 
102
 
103
  with block:
104
- gr.HTML(
105
- """
106
- <div style="text-align: center; max-width: 650px; margin: 0 auto;">
107
- <div
108
- style="
109
- display: inline-flex;
110
- align-items: center;
111
- gap: 0.8rem;
112
- font-size: 1.75rem;
113
- "
114
- >
115
- <svg
116
- width="0.65em"
117
- height="0.65em"
118
- viewBox="0 0 115 115"
119
- fill="none"
120
- xmlns="http://www.w3.org/2000/svg"
121
- >
122
- <rect width="23" height="23" fill="white"></rect>
123
- <rect y="69" width="23" height="23" fill="white"></rect>
124
- <rect x="23" width="23" height="23" fill="#AEAEAE"></rect>
125
- <rect x="23" y="69" width="23" height="23" fill="#AEAEAE"></rect>
126
- <rect x="46" width="23" height="23" fill="white"></rect>
127
- <rect x="46" y="69" width="23" height="23" fill="white"></rect>
128
- <rect x="69" width="23" height="23" fill="black"></rect>
129
- <rect x="69" y="69" width="23" height="23" fill="black"></rect>
130
- <rect x="92" width="23" height="23" fill="#D9D9D9"></rect>
131
- <rect x="92" y="69" width="23" height="23" fill="#AEAEAE"></rect>
132
- <rect x="115" y="46" width="23" height="23" fill="white"></rect>
133
- <rect x="115" y="115" width="23" height="23" fill="white"></rect>
134
- <rect x="115" y="69" width="23" height="23" fill="#D9D9D9"></rect>
135
- <rect x="92" y="46" width="23" height="23" fill="#AEAEAE"></rect>
136
- <rect x="92" y="115" width="23" height="23" fill="#AEAEAE"></rect>
137
- <rect x="92" y="69" width="23" height="23" fill="white"></rect>
138
- <rect x="69" y="46" width="23" height="23" fill="white"></rect>
139
- <rect x="69" y="115" width="23" height="23" fill="white"></rect>
140
- <rect x="69" y="69" width="23" height="23" fill="#D9D9D9"></rect>
141
- <rect x="46" y="46" width="23" height="23" fill="black"></rect>
142
- <rect x="46" y="115" width="23" height="23" fill="black"></rect>
143
- <rect x="46" y="69" width="23" height="23" fill="black"></rect>
144
- <rect x="23" y="46" width="23" height="23" fill="#D9D9D9"></rect>
145
- <rect x="23" y="115" width="23" height="23" fill="#AEAEAE"></rect>
146
- <rect x="23" y="69" width="23" height="23" fill="black"></rect>
147
- </svg>
148
- <h1 style="font-weight: 900; margin-bottom: 7px;">
149
- Whisper
150
- </h1>
151
- </div>
152
- <p style="margin-bottom: 10px; font-size: 94%">
153
- 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.
154
- </p>
155
- <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>
156
- </div>
157
- """
158
- )
159
  with gr.Group():
160
  with gr.Box():
161
  with gr.Row().style(mobile_collapse=False, equal_height=True):
@@ -173,8 +42,7 @@ with block:
173
 
174
  gr.HTML('''
175
  <div class="footer">
176
- <p>Model by <a href="https://github.com/openai/whisper" style="text-decoration: underline;" target="_blank">OpenAI</a> - Gradio Demo by 🤗 Hugging Face
177
- </p>
178
  </div>
179
  ''')
180
 
 
18
  result = whisper.decode(model, mel, options)
19
 
20
  print(result.text)
21
+ return result.text
22
 
23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  block = gr.Blocks(css=css)
25
 
26
 
27
  with block:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  with gr.Group():
29
  with gr.Box():
30
  with gr.Row().style(mobile_collapse=False, equal_height=True):
 
42
 
43
  gr.HTML('''
44
  <div class="footer">
45
+ <p>This space is used by VideoChain, the all-in-one API to generate video, audio and more.</p>
 
46
  </div>
47
  ''')
48