Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,7 @@ import spaces
|
|
4 |
import torch
|
5 |
|
6 |
from transformers import pipeline
|
|
|
7 |
|
8 |
# Pre-Initialize
|
9 |
DEVICE = "auto"
|
@@ -15,7 +16,9 @@ print(f"[SYSTEM] | Using {DEVICE} type compute device.")
|
|
15 |
DEFAULT_TASK = "transcribe"
|
16 |
BATCH_SIZE = 8
|
17 |
|
18 |
-
repo = pipeline(task="automatic-speech-recognition", model="deepdml/faster-whisper-large-v3-turbo-ct2", chunk_length_s=30, device=DEVICE)
|
|
|
|
|
19 |
|
20 |
css = '''
|
21 |
.gradio-container{max-width: 560px !important}
|
@@ -29,8 +32,12 @@ footer {
|
|
29 |
def transcribe(input=None, task=DEFAULT_TASK):
|
30 |
print(input)
|
31 |
if input is None: raise gr.Error("Invalid input.")
|
32 |
-
|
33 |
-
|
|
|
|
|
|
|
|
|
34 |
|
35 |
def cloud():
|
36 |
print("[CLOUD] | Space maintained.")
|
|
|
4 |
import torch
|
5 |
|
6 |
from transformers import pipeline
|
7 |
+
from faster_whisper import WhisperModel
|
8 |
|
9 |
# Pre-Initialize
|
10 |
DEVICE = "auto"
|
|
|
16 |
DEFAULT_TASK = "transcribe"
|
17 |
BATCH_SIZE = 8
|
18 |
|
19 |
+
# repo = pipeline(task="automatic-speech-recognition", model="deepdml/faster-whisper-large-v3-turbo-ct2", chunk_length_s=30, device=DEVICE)
|
20 |
+
|
21 |
+
repo = WhisperModel("faster-whisper-large-v3-turbo-ct2")
|
22 |
|
23 |
css = '''
|
24 |
.gradio-container{max-width: 560px !important}
|
|
|
32 |
def transcribe(input=None, task=DEFAULT_TASK):
|
33 |
print(input)
|
34 |
if input is None: raise gr.Error("Invalid input.")
|
35 |
+
|
36 |
+
segments, info = model.transcribe(input)
|
37 |
+
print(segments)
|
38 |
+
print(info)
|
39 |
+
# output = repo(input, batch_size=BATCH_SIZE, generate_kwargs={"task": task}, return_timestamps=True)["text"]
|
40 |
+
return segments
|
41 |
|
42 |
def cloud():
|
43 |
print("[CLOUD] | Space maintained.")
|