sanchit-gandhi HF staff commited on
Commit
8bda11a
1 Parent(s): 7c1a8fa

add examples

Browse files
Files changed (4) hide show
  1. .gitattributes +1 -0
  2. app.py +12 -1
  3. assets/example_1.wav +3 -0
  4. assets/example_2.wav +3 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ *wav filter=lfs diff=lfs merge=lfs -text
app.py CHANGED
@@ -82,7 +82,7 @@ def transcribe(inputs):
82
  return result
83
 
84
  distil_pipe._forward = _forward_distil_time
85
- distil_text = distil_pipe(inputs, batch_size=BATCH_SIZE)["text"]
86
  yield distil_text, distil_runtime, None, None, None
87
 
88
  def _forward_time(*args, **kwargs):
@@ -99,6 +99,9 @@ def transcribe(inputs):
99
  yield distil_text, distil_runtime, text, runtime
100
 
101
  if __name__ == "__main__":
 
 
 
102
  with gr.Blocks() as demo:
103
  gr.HTML(
104
  """
@@ -136,4 +139,12 @@ if __name__ == "__main__":
136
  inputs=audio,
137
  outputs=[distil_transcription, distil_runtime, transcription, runtime],
138
  )
 
 
 
 
 
 
 
 
139
  demo.queue(max_size=10).launch()
 
82
  return result
83
 
84
  distil_pipe._forward = _forward_distil_time
85
+ distil_text = distil_pipe(inputs.copy(), batch_size=BATCH_SIZE)["text"]
86
  yield distil_text, distil_runtime, None, None, None
87
 
88
  def _forward_time(*args, **kwargs):
 
99
  yield distil_text, distil_runtime, text, runtime
100
 
101
  if __name__ == "__main__":
102
+ # CUDA warm-up step so that we don't count it in our examples
103
+ _ = distil_pipe("./assets/example_1.wav")
104
+
105
  with gr.Blocks() as demo:
106
  gr.HTML(
107
  """
 
139
  inputs=audio,
140
  outputs=[distil_transcription, distil_runtime, transcription, runtime],
141
  )
142
+ gr.Markdown("## Examples")
143
+ gr.Examples(
144
+ [["./assets/example_1.wav"], ["./assets/example_2.wav"]],
145
+ audio,
146
+ outputs=[distil_transcription, distil_runtime, transcription, runtime],
147
+ fn=transcribe,
148
+ cache_examples=True,
149
+ )
150
  demo.queue(max_size=10).launch()
assets/example_1.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1e938b9f81dea096ec7d3752e90afca8d370f7a461d3a08e1a559f4440ed055d
3
+ size 1963810
assets/example_2.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:81fc0857f7fe11416ede431db713a02fdb787bbc049802fe74c791f3b44e5bf4
3
+ size 1920044