mikr commited on
Commit
9963f1b
1 Parent(s): 68e29a8
Files changed (1) hide show
  1. app.py +4 -14
app.py CHANGED
@@ -13,20 +13,12 @@ pipe = pipeline(
13
  device=device,
14
  )
15
 
16
- pipe.model.config.forced_decoder_ids = pipe.tokenizer.get_decoder_prompt_ids(language=lang, task="transcribe")
17
-
18
- def transcribe(microphone, file_upload):
19
  warn_output = ""
20
- if (microphone is not None) and (file_upload is not None):
21
- warn_output = (
22
- "WARNING: You've uploaded an audio file and used the microphone. "
23
- "The recorded file from the microphone will be used and the uploaded audio will be discarded.\n"
24
- )
25
-
26
- elif (microphone is None) and (file_upload is None):
27
  return "ERROR: You have to either use the microphone or upload an audio file"
28
 
29
- file = microphone if microphone is not None else file_upload
30
 
31
  text = pipe(file)["text"]
32
 
@@ -36,11 +28,9 @@ def transcribe(microphone, file_upload):
36
  iface = gr.Interface(
37
  fn=transcribe,
38
  inputs=[
39
- gr.inputs.Audio(source="microphone", type="filepath", optional=True),
40
- gr.inputs.Audio(source="upload", type="filepath", optional=True),
41
  ],
42
  outputs="text",
43
- layout="horizontal",
44
  theme="huggingface",
45
  title="Wav2Vec2-Bert demo - transcribe Czech Audio",
46
  description=(
 
13
  device=device,
14
  )
15
 
16
+ def transcribe(file_upload):
 
 
17
  warn_output = ""
18
+ if (file_upload is None):
 
 
 
 
 
 
19
  return "ERROR: You have to either use the microphone or upload an audio file"
20
 
21
+ file = file_upload
22
 
23
  text = pipe(file)["text"]
24
 
 
28
  iface = gr.Interface(
29
  fn=transcribe,
30
  inputs=[
31
+ gr.File(type="binary", label="Upload Audio File"), # Audio file upload
 
32
  ],
33
  outputs="text",
 
34
  theme="huggingface",
35
  title="Wav2Vec2-Bert demo - transcribe Czech Audio",
36
  description=(