Aspik101 commited on
Commit
47ad873
Β·
1 Parent(s): 2eb8b8f

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +168 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ pipe = pipeline(
5
+ "automatic-speech-recognition",
6
+ model="Aspik101/whisper-tiny-pl",
7
+ chunk_length_s=30
8
+ )
9
+
10
+
11
+
12
+ def inference(audio):
13
+ return pipe(audio)['text']
14
+
15
+
16
+ title="Polish Fine Tuned Whisper"
17
+
18
+ description='Polish Fine Tuned Whisper was trained on a Polish common voice dataset during the "Whisper fine-tuning event". The basic tiny model is implemented in the application, which may affect the quality of transcription. You can use trained larger models for your own use.'
19
+
20
+ css = """
21
+
22
+ .gradio-container {
23
+ font-family: 'IBM Plex Sans', sans-serif;
24
+ }
25
+ .gr-button {
26
+ color: white;
27
+ border-color: black;
28
+ background: black;
29
+ }
30
+ input[type='range'] {
31
+ accent-color: black;
32
+ }
33
+ .dark input[type='range'] {
34
+ accent-color: #dfdfdf;
35
+ }
36
+ .container {
37
+ max-width: 730px;
38
+ margin: auto;
39
+ padding-top: 1.5rem;
40
+ }
41
+
42
+ .details:hover {
43
+ text-decoration: underline;
44
+ }
45
+ .gr-button {
46
+ white-space: nowrap;
47
+ }
48
+ .gr-button:focus {
49
+ border-color: rgb(147 197 253 / var(--tw-border-opacity));
50
+ outline: none;
51
+ box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
52
+ --tw-border-opacity: 1;
53
+ --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
54
+ --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(3px var(--tw-ring-offset-width)) var(--tw-ring-color);
55
+ --tw-ring-color: rgb(191 219 254 / var(--tw-ring-opacity));
56
+ --tw-ring-opacity: .5;
57
+ }
58
+ .footer {
59
+ margin-bottom: 45px;
60
+ margin-top: 35px;
61
+ text-align: center;
62
+ border-bottom: 1px solid #e5e5e5;
63
+ }
64
+ .footer>p {
65
+ font-size: .8rem;
66
+ display: inline-block;
67
+ padding: 0 10px;
68
+ transform: translateY(10px);
69
+ background: white;
70
+ }
71
+ .dark .footer {
72
+ border-color: #303030;
73
+ }
74
+ .dark .footer>p {
75
+ background: #0b0f19;
76
+ }
77
+ .prompt h4{
78
+ margin: 1.25em 0 .25em 0;
79
+ font-weight: bold;
80
+ font-size: 115%;
81
+ }
82
+ """
83
+
84
+ block = gr.Blocks(css=css)
85
+
86
+
87
+
88
+ with block:
89
+ gr.HTML(
90
+ """
91
+ <div style="text-align: center; max-width: 650px; margin: 0 auto;">
92
+ <div
93
+ style="
94
+ display: inline-flex;
95
+ align-items: center;
96
+ gap: 0.8rem;
97
+ font-size: 1.75rem;
98
+ "
99
+ >
100
+ <svg
101
+ width="0.65em"
102
+ height="0.65em"
103
+ viewBox="0 0 115 115"
104
+ fill="none"
105
+ xmlns="http://www.w3.org/2000/svg"
106
+ >
107
+ <rect width="23" height="23" fill="white"></rect>
108
+ <rect y="69" width="23" height="23" fill="white"></rect>
109
+ <rect x="23" width="23" height="23" fill="#AEAEAE"></rect>
110
+ <rect x="23" y="69" width="23" height="23" fill="#AEAEAE"></rect>
111
+ <rect x="46" width="23" height="23" fill="white"></rect>
112
+ <rect x="46" y="69" width="23" height="23" fill="white"></rect>
113
+ <rect x="69" width="23" height="23" fill="black"></rect>
114
+ <rect x="69" y="69" width="23" height="23" fill="black"></rect>
115
+ <rect x="92" width="23" height="23" fill="#D9D9D9"></rect>
116
+ <rect x="92" y="69" width="23" height="23" fill="#AEAEAE"></rect>
117
+ <rect x="115" y="46" width="23" height="23" fill="white"></rect>
118
+ <rect x="115" y="115" width="23" height="23" fill="white"></rect>
119
+ <rect x="115" y="69" width="23" height="23" fill="#D9D9D9"></rect>
120
+ <rect x="92" y="46" width="23" height="23" fill="#AEAEAE"></rect>
121
+ <rect x="92" y="115" width="23" height="23" fill="#AEAEAE"></rect>
122
+ <rect x="92" y="69" width="23" height="23" fill="white"></rect>
123
+ <rect x="69" y="46" width="23" height="23" fill="white"></rect>
124
+ <rect x="69" y="115" width="23" height="23" fill="white"></rect>
125
+ <rect x="69" y="69" width="23" height="23" fill="#D9D9D9"></rect>
126
+ <rect x="46" y="46" width="23" height="23" fill="black"></rect>
127
+ <rect x="46" y="115" width="23" height="23" fill="black"></rect>
128
+ <rect x="46" y="69" width="23" height="23" fill="black"></rect>
129
+ <rect x="23" y="46" width="23" height="23" fill="#D9D9D9"></rect>
130
+ <rect x="23" y="115" width="23" height="23" fill="#AEAEAE"></rect>
131
+ <rect x="23" y="69" width="23" height="23" fill="black"></rect>
132
+ </svg>
133
+ <h1 style="font-weight: 900; margin-bottom: 7px;">
134
+ Whisper
135
+ </h1>
136
+ </div>
137
+ <p style="margin-bottom: 10px; font-size: 94%">
138
+ Polish Fine Tuned Whisper was trained on a Polish common voice dataset during the "Whisper fine-tuning event". The basic tiny model is implemented in the application, which may affect the quality of transcription. You can use trained larger models for your own use.'
139
+ </p>
140
+ </div>
141
+ """
142
+ )
143
+ with gr.Group():
144
+ with gr.Box():
145
+ with gr.Row().style(mobile_collapse=False, equal_height=True):
146
+ audio = gr.Audio(
147
+ label="Input Audio",
148
+ show_label=False,
149
+ source="upload",
150
+ type="filepath"
151
+ )
152
+
153
+ btn = gr.Button("Transcribe")
154
+ text = gr.Textbox(show_label=False)
155
+
156
+
157
+
158
+
159
+ btn.click(inference, inputs=[audio], outputs=[text])
160
+
161
+ gr.HTML('''
162
+ <div class="footer">
163
+ <p>Model by <a href="https://github.com/openai/whisper" style="text-decoration: underline;" target="_blank">OpenAI</a> - Gradio Demo by πŸ€— Hugging Face
164
+ </p>
165
+ </div>
166
+ ''')
167
+
168
+ block.launch(share = False)
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ torch
2
+ transformers
3
+ gradio