tomaseo2022 commited on
Commit
a7382f1
·
1 Parent(s): 11ef799

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -173
app.py DELETED
@@ -1,173 +0,0 @@
1
- import os
2
- os.system("pip install git+https://github.com/openai/whisper.git")
3
- import gradio as gr
4
- import whisper
5
-
6
- from share_btn import community_icon_html, loading_icon_html, share_js
7
-
8
- model = whisper.load_model("small")
9
-
10
-
11
-
12
- def inference(audio):
13
- audio = whisper.load_audio(audio)
14
- audio = whisper.pad_or_trim(audio)
15
-
16
- mel = whisper.log_mel_spectrogram(audio).to(model.device)
17
-
18
- _, probs = model.detect_language(mel)
19
-
20
- options = whisper.DecodingOptions(fp16 = False)
21
- result = whisper.decode(model, mel, options)
22
-
23
- print(result.text)
24
- return result.text, gr.update(visible=True), gr.update(visible=True), gr.update(visible=True)
25
-
26
-
27
-
28
-
29
- css = """
30
- .gradio-container {
31
- font-family: 'IBM Plex Sans', sans-serif;
32
- }
33
- .gr-button {
34
- color: white;
35
- border-color: black;
36
- background: black;
37
- }
38
- input[type='range'] {
39
- accent-color: black;
40
- }
41
- .dark input[type='range'] {
42
- accent-color: #dfdfdf;
43
- }
44
- .container {
45
- max-width: 730px;
46
- margin: auto;
47
- padding-top: 1.5rem;
48
- }
49
-
50
- .details:hover {
51
- text-decoration: underline;
52
- }
53
- .gr-button {
54
- white-space: nowrap;
55
- }
56
- .gr-button:focus {
57
- border-color: rgb(147 197 253 / var(--tw-border-opacity));
58
- outline: none;
59
- box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
60
- --tw-border-opacity: 1;
61
- --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
62
- --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(3px var(--tw-ring-offset-width)) var(--tw-ring-color);
63
- --tw-ring-color: rgb(191 219 254 / var(--tw-ring-opacity));
64
- --tw-ring-opacity: .5;
65
- }
66
-
67
- .prompt h4{
68
- margin: 1.25em 0 .25em 0;
69
- font-weight: bold;
70
- font-size: 115%;
71
- }
72
- .animate-spin {
73
- animation: spin 1s linear infinite;
74
- }
75
- @keyframes spin {
76
- from {
77
- transform: rotate(0deg);
78
- }
79
- to {
80
- transform: rotate(360deg);
81
- }
82
- }
83
- #share-btn-container {
84
- 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;
85
- }
86
- #share-btn {
87
- 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;
88
- }
89
- #share-btn * {
90
- all: unset;
91
- }
92
- """
93
-
94
- block = gr.Blocks(css=css)
95
-
96
-
97
-
98
- with block:
99
- gr.HTML(
100
- """
101
- <div style="text-align: center; max-width: 650px; margin: 0 auto;">
102
- <div
103
- style="
104
- display: inline-flex;
105
- align-items: center;
106
- gap: 0.8rem;
107
- font-size: 1.75rem;
108
- "
109
- >
110
- <svg
111
- width="0.65em"
112
- height="0.65em"
113
- viewBox="0 0 115 115"
114
- fill="none"
115
- xmlns="http://www.w3.org/2000/svg"
116
- >
117
- <rect width="23" height="23" fill="white"></rect>
118
- <rect y="69" width="23" height="23" fill="white"></rect>
119
- <rect x="23" width="23" height="23" fill="#AEAEAE"></rect>
120
- <rect x="23" y="69" width="23" height="23" fill="#AEAEAE"></rect>
121
- <rect x="46" width="23" height="23" fill="white"></rect>
122
- <rect x="46" y="69" width="23" height="23" fill="white"></rect>
123
- <rect x="69" width="23" height="23" fill="black"></rect>
124
- <rect x="69" y="69" width="23" height="23" fill="black"></rect>
125
- <rect x="92" width="23" height="23" fill="#D9D9D9"></rect>
126
- <rect x="92" y="69" width="23" height="23" fill="#AEAEAE"></rect>
127
- <rect x="115" y="46" width="23" height="23" fill="white"></rect>
128
- <rect x="115" y="115" width="23" height="23" fill="white"></rect>
129
- <rect x="115" y="69" width="23" height="23" fill="#D9D9D9"></rect>
130
- <rect x="92" y="46" width="23" height="23" fill="#AEAEAE"></rect>
131
- <rect x="92" y="115" width="23" height="23" fill="#AEAEAE"></rect>
132
- <rect x="92" y="69" width="23" height="23" fill="white"></rect>
133
- <rect x="69" y="46" width="23" height="23" fill="white"></rect>
134
- <rect x="69" y="115" width="23" height="23" fill="white"></rect>
135
- <rect x="69" y="69" width="23" height="23" fill="#D9D9D9"></rect>
136
- <rect x="46" y="46" width="23" height="23" fill="black"></rect>
137
- <rect x="46" y="115" width="23" height="23" fill="black"></rect>
138
- <rect x="46" y="69" width="23" height="23" fill="black"></rect>
139
- <rect x="23" y="46" width="23" height="23" fill="#D9D9D9"></rect>
140
- <rect x="23" y="115" width="23" height="23" fill="#AEAEAE"></rect>
141
- <rect x="23" y="69" width="23" height="23" fill="black"></rect>
142
- </svg>
143
- <h1 style="font-weight: 900; margin-bottom: 7px;">
144
- Whisper
145
- </h1>
146
- </div>
147
- </div>
148
- """
149
- )
150
- with gr.Group():
151
- with gr.Box():
152
- with gr.Row().style(mobile_collapse=False, equal_height=True):
153
- audio = gr.Audio(
154
- label="Input Audio",
155
- show_label=False,
156
- source="microphone",
157
- type="filepath"
158
- )
159
-
160
- btn = gr.Button("Transcribe")
161
- text = gr.Textbox(show_label=False, elem_id="result-textarea")
162
- with gr.Group(elem_id="share-btn-container"):
163
- loading_icon = gr.HTML(loading_icon_html, visible=False)
164
-
165
-
166
-
167
-
168
-
169
- btn.click(inference, inputs=[audio], outputs=[text, loading_icon])
170
-
171
-
172
-
173
- block.launch()