Spaces:
Running
on
Zero
Running
on
Zero
sanchit-gandhi
commited on
Commit
·
77ac2cf
1
Parent(s):
7bd1e74
fix bugs
Browse files- app.py +9 -9
- assets/example_1.wav +2 -2
- assets/example_2.wav +2 -2
app.py
CHANGED
@@ -78,32 +78,32 @@ def transcribe(inputs):
|
|
78 |
inputs = {"array": inputs, "sampling_rate": pipe.feature_extractor.sampling_rate}
|
79 |
|
80 |
def _forward_distil_time(*args, **kwargs):
|
81 |
-
global
|
82 |
start_time = time.time()
|
83 |
result = distil_pipe_forward(*args, **kwargs)
|
84 |
-
|
85 |
-
|
86 |
return result
|
87 |
|
88 |
distil_pipe._forward = _forward_distil_time
|
89 |
distil_text = distil_pipe(inputs.copy(), batch_size=BATCH_SIZE)["text"]
|
90 |
-
yield distil_text,
|
91 |
|
92 |
def _forward_time(*args, **kwargs):
|
93 |
-
global
|
94 |
start_time = time.time()
|
95 |
result = pipe_forward(*args, **kwargs)
|
96 |
-
|
97 |
-
|
98 |
return result
|
99 |
|
100 |
pipe._forward = _forward_time
|
101 |
text = pipe(inputs, batch_size=BATCH_SIZE)["text"]
|
102 |
|
103 |
-
yield distil_text,
|
104 |
|
105 |
else:
|
106 |
-
input_features = processor(inputs, sampling_rate=processor.feature_extractor.sampling_rate, return_tensors="pt")
|
107 |
|
108 |
# Run the generation in a separate thread, so that we can fetch the generated text in a non-blocking way.
|
109 |
generation_kwargs = dict(input_features, streamer=streamer, max_new_tokens=128, language="en", task="transcribe")
|
|
|
78 |
inputs = {"array": inputs, "sampling_rate": pipe.feature_extractor.sampling_rate}
|
79 |
|
80 |
def _forward_distil_time(*args, **kwargs):
|
81 |
+
global distil_runtime_pipeline
|
82 |
start_time = time.time()
|
83 |
result = distil_pipe_forward(*args, **kwargs)
|
84 |
+
distil_runtime_pipeline = time.time() - start_time
|
85 |
+
distil_runtime_pipeline = round(distil_runtime_pipeline, 2)
|
86 |
return result
|
87 |
|
88 |
distil_pipe._forward = _forward_distil_time
|
89 |
distil_text = distil_pipe(inputs.copy(), batch_size=BATCH_SIZE)["text"]
|
90 |
+
yield distil_text, distil_runtime_pipeline, None, None
|
91 |
|
92 |
def _forward_time(*args, **kwargs):
|
93 |
+
global runtime_pipeline
|
94 |
start_time = time.time()
|
95 |
result = pipe_forward(*args, **kwargs)
|
96 |
+
runtime_pipeline = time.time() - start_time
|
97 |
+
runtime_pipeline = round(runtime_pipeline, 2)
|
98 |
return result
|
99 |
|
100 |
pipe._forward = _forward_time
|
101 |
text = pipe(inputs, batch_size=BATCH_SIZE)["text"]
|
102 |
|
103 |
+
yield distil_text, distil_runtime_pipeline, text, runtime_pipeline
|
104 |
|
105 |
else:
|
106 |
+
input_features = processor(inputs, sampling_rate=processor.feature_extractor.sampling_rate, return_tensors="pt")
|
107 |
|
108 |
# Run the generation in a separate thread, so that we can fetch the generated text in a non-blocking way.
|
109 |
generation_kwargs = dict(input_features, streamer=streamer, max_new_tokens=128, language="en", task="transcribe")
|
assets/example_1.wav
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d96fece5c0c24d039801e9e39e9985982ad63becdab6c1a141992aa6dd37a615
|
3 |
+
size 802110
|
assets/example_2.wav
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1e938b9f81dea096ec7d3752e90afca8d370f7a461d3a08e1a559f4440ed055d
|
3 |
+
size 1963810
|