almncarlo commited on
Commit
6279449
·
verified ·
1 Parent(s): 843bc29

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +78 -78
app.py CHANGED
@@ -142,84 +142,84 @@ def transcribe(audio_filepath, src_lang, tgt_lang, pnc):
142
  return output_text
143
 
144
  # add logic to make sure dropdown menus only suggest valid combos
145
- def on_src_or_tgt_lang_change(src_lang_value, tgt_lang_value, pnc_value):
146
- """Callback function for when src_lang or tgt_lang dropdown menus are changed.
147
-
148
- Args:
149
- src_lang_value(string), tgt_lang_value (string), pnc_value(bool) - the current
150
- chosen "values" of each Gradio component
151
- Returns:
152
- src_lang, tgt_lang, pnc - these are the new Gradio components that will be displayed
153
-
154
- """
155
-
156
- if src_lang_value == "English" and tgt_lang_value == "English":
157
- # src_lang and tgt_lang can go anywhere
158
- src_lang = gr.Dropdown(
159
- choices=["English", "Spanish", "French", "German"],
160
- value=src_lang_value,
161
- label="Input audio is spoken in:"
162
- )
163
- tgt_lang = gr.Dropdown(
164
- choices=["English", "Spanish", "French", "German"],
165
- value=tgt_lang_value,
166
- label="Transcribe in language:"
167
- )
168
- elif src_lang_value == "English":
169
- # src is English & tgt is non-English
170
- # => src can only be English or current tgt_lang_values
171
- # & tgt can be anything
172
- src_lang = gr.Dropdown(
173
- choices=["English", tgt_lang_value],
174
- value=src_lang_value,
175
- label="Input audio is spoken in:"
176
- )
177
- tgt_lang = gr.Dropdown(
178
- choices=["English", "Spanish", "French", "German"],
179
- value=tgt_lang_value,
180
- label="Transcribe in language:"
181
- )
182
- elif tgt_lang_value == "English":
183
- # src is non-English & tgt is English
184
- # => src can be anything
185
- # & tgt can only be English or current src_lang_value
186
- src_lang = gr.Dropdown(
187
- choices=["English", "Spanish", "French", "German"],
188
- value=src_lang_value,
189
- label="Input audio is spoken in:"
190
- )
191
- tgt_lang = gr.Dropdown(
192
- choices=["English", src_lang_value],
193
- value=tgt_lang_value,
194
- label="Transcribe in language:"
195
- )
196
- else:
197
- # both src and tgt are non-English
198
- # => both src and tgt can only be switch to English or themselves
199
- src_lang = gr.Dropdown(
200
- choices=["English", src_lang_value],
201
- value=src_lang_value,
202
- label="Input audio is spoken in:"
203
- )
204
- tgt_lang = gr.Dropdown(
205
- choices=["English", tgt_lang_value],
206
- value=tgt_lang_value,
207
- label="Transcribe in language:"
208
- )
209
- # let pnc be anything if src_lang_value == tgt_lang_value, else fix to True
210
- if src_lang_value == tgt_lang_value:
211
- pnc = gr.Checkbox(
212
- value=pnc_value,
213
- label="Punctuation & Capitalization in transcript?",
214
- interactive=True
215
- )
216
- else:
217
- pnc = gr.Checkbox(
218
- value=True,
219
- label="Punctuation & Capitalization in transcript?",
220
- interactive=False
221
- )
222
- return src_lang, tgt_lang, pnc
223
 
224
 
225
  with gr.Blocks(
 
142
  return output_text
143
 
144
  # add logic to make sure dropdown menus only suggest valid combos
145
+ # def on_src_or_tgt_lang_change(src_lang_value, tgt_lang_value, pnc_value):
146
+ # """Callback function for when src_lang or tgt_lang dropdown menus are changed.
147
+
148
+ # Args:
149
+ # src_lang_value(string), tgt_lang_value (string), pnc_value(bool) - the current
150
+ # chosen "values" of each Gradio component
151
+ # Returns:
152
+ # src_lang, tgt_lang, pnc - these are the new Gradio components that will be displayed
153
+
154
+ # """
155
+
156
+ # if src_lang_value == "English" and tgt_lang_value == "English":
157
+ # # src_lang and tgt_lang can go anywhere
158
+ # src_lang = gr.Dropdown(
159
+ # choices=["English", "Spanish", "French", "German"],
160
+ # value=src_lang_value,
161
+ # label="Input audio is spoken in:"
162
+ # )
163
+ # tgt_lang = gr.Dropdown(
164
+ # choices=["English", "Spanish", "French", "German"],
165
+ # value=tgt_lang_value,
166
+ # label="Transcribe in language:"
167
+ # )
168
+ # elif src_lang_value == "English":
169
+ # # src is English & tgt is non-English
170
+ # # => src can only be English or current tgt_lang_values
171
+ # # & tgt can be anything
172
+ # src_lang = gr.Dropdown(
173
+ # choices=["English", tgt_lang_value],
174
+ # value=src_lang_value,
175
+ # label="Input audio is spoken in:"
176
+ # )
177
+ # tgt_lang = gr.Dropdown(
178
+ # choices=["English", "Spanish", "French", "German"],
179
+ # value=tgt_lang_value,
180
+ # label="Transcribe in language:"
181
+ # )
182
+ # elif tgt_lang_value == "English":
183
+ # # src is non-English & tgt is English
184
+ # # => src can be anything
185
+ # # & tgt can only be English or current src_lang_value
186
+ # src_lang = gr.Dropdown(
187
+ # choices=["English", "Spanish", "French", "German"],
188
+ # value=src_lang_value,
189
+ # label="Input audio is spoken in:"
190
+ # )
191
+ # tgt_lang = gr.Dropdown(
192
+ # choices=["English", src_lang_value],
193
+ # value=tgt_lang_value,
194
+ # label="Transcribe in language:"
195
+ # )
196
+ # else:
197
+ # # both src and tgt are non-English
198
+ # # => both src and tgt can only be switch to English or themselves
199
+ # src_lang = gr.Dropdown(
200
+ # choices=["English", src_lang_value],
201
+ # value=src_lang_value,
202
+ # label="Input audio is spoken in:"
203
+ # )
204
+ # tgt_lang = gr.Dropdown(
205
+ # choices=["English", tgt_lang_value],
206
+ # value=tgt_lang_value,
207
+ # label="Transcribe in language:"
208
+ # )
209
+ # # let pnc be anything if src_lang_value == tgt_lang_value, else fix to True
210
+ # if src_lang_value == tgt_lang_value:
211
+ # pnc = gr.Checkbox(
212
+ # value=pnc_value,
213
+ # label="Punctuation & Capitalization in transcript?",
214
+ # interactive=True
215
+ # )
216
+ # else:
217
+ # pnc = gr.Checkbox(
218
+ # value=True,
219
+ # label="Punctuation & Capitalization in transcript?",
220
+ # interactive=False
221
+ # )
222
+ # return src_lang, tgt_lang, pnc
223
 
224
 
225
  with gr.Blocks(