kmknair commited on
Commit
649f719
·
1 Parent(s): 478bedf

added upload and mic option for file tab

Browse files
Files changed (1) hide show
  1. app.py +15 -4
app.py CHANGED
@@ -10,8 +10,13 @@ p_ta = pipeline("automatic-speech-recognition", model="kmknair/wav2vec2-xlsr-tam
10
  p_ar = pipeline("automatic-speech-recognition", model="kmknair/wav2vec2-xlsr-arabic")
11
 
12
 
13
- def transcribe_ta(audio):
14
- text = p_ta(audio)["text"]
 
 
 
 
 
15
  return text
16
 
17
  def transcribe_ta_stream(audio, state=""):
@@ -20,8 +25,12 @@ def transcribe_ta_stream(audio, state=""):
20
  state += text + " "
21
  return state, state
22
 
23
- def transcribe_ar(audio):
24
- text = p_ar(audio)["text"]
 
 
 
 
25
  return text
26
 
27
  def transcribe_ar_stream(audio, state=""):
@@ -59,6 +68,7 @@ ar_tr_stream_tab = gr.Interface(
59
  ta_tr_file_tab = gr.Interface(
60
  fn=transcribe_ta,
61
  inputs=[
 
62
  gr.Audio(source="microphone", type="filepath")
63
  ],
64
  outputs="text")
@@ -67,6 +77,7 @@ ta_tr_file_tab = gr.Interface(
67
  ar_tr_file_tab = gr.Interface(
68
  fn=transcribe_ar,
69
  inputs=[
 
70
  gr.Audio(source="microphone", type="filepath")
71
  ],
72
  outputs="text")
 
10
  p_ar = pipeline("automatic-speech-recognition", model="kmknair/wav2vec2-xlsr-arabic")
11
 
12
 
13
+ def transcribe_ta(audio_u, audio_m):
14
+ text = ""
15
+ if(audio_u is not None):
16
+ text += p_ta(audio_u)["text"]
17
+ if (audio_m is not None):
18
+ text += p_ta(audio_m)["text"]
19
+
20
  return text
21
 
22
  def transcribe_ta_stream(audio, state=""):
 
25
  state += text + " "
26
  return state, state
27
 
28
+ def transcribe_ar(audio_u, audio_m):
29
+ text = ""
30
+ if audio_u is not None:
31
+ text += p_ar(audio_u)["text"]
32
+ if audio_m is not None:
33
+ text += p_ar(audio_m)["text"]
34
  return text
35
 
36
  def transcribe_ar_stream(audio, state=""):
 
68
  ta_tr_file_tab = gr.Interface(
69
  fn=transcribe_ta,
70
  inputs=[
71
+ gr.Audio(type="filepath"),
72
  gr.Audio(source="microphone", type="filepath")
73
  ],
74
  outputs="text")
 
77
  ar_tr_file_tab = gr.Interface(
78
  fn=transcribe_ar,
79
  inputs=[
80
+ gr.Audio(type="filepath"),
81
  gr.Audio(source="microphone", type="filepath")
82
  ],
83
  outputs="text")