Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -13,13 +13,12 @@ lang = "fi"
|
|
13 |
|
14 |
share = (os.environ.get("SHARE", "False")[0].lower() in "ty1") or None
|
15 |
auth_token = os.environ.get("AUTH_TOKEN") or True
|
16 |
-
device = 0 if torch.cuda.is_available() else "cpu"
|
17 |
print(f"Using device: {device}")
|
18 |
pipe = pipeline(
|
19 |
task="automatic-speech-recognition",
|
20 |
model=MODEL_NAME,
|
21 |
chunk_length_s=30,
|
22 |
-
device=device,
|
23 |
token=auth_token,
|
24 |
)
|
25 |
|
@@ -27,6 +26,7 @@ pipe.model.config.forced_decoder_ids = pipe.tokenizer.get_decoder_prompt_ids(lan
|
|
27 |
|
28 |
@spaces.GPU(duration=120)
|
29 |
def transcribe(microphone, file_upload):
|
|
|
30 |
warn_output = ""
|
31 |
if (microphone is not None) and (file_upload is not None):
|
32 |
warn_output = (
|
|
|
13 |
|
14 |
share = (os.environ.get("SHARE", "False")[0].lower() in "ty1") or None
|
15 |
auth_token = os.environ.get("AUTH_TOKEN") or True
|
16 |
+
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
17 |
print(f"Using device: {device}")
|
18 |
pipe = pipeline(
|
19 |
task="automatic-speech-recognition",
|
20 |
model=MODEL_NAME,
|
21 |
chunk_length_s=30,
|
|
|
22 |
token=auth_token,
|
23 |
)
|
24 |
|
|
|
26 |
|
27 |
@spaces.GPU(duration=120)
|
28 |
def transcribe(microphone, file_upload):
|
29 |
+
pipe.to(device)
|
30 |
warn_output = ""
|
31 |
if (microphone is not None) and (file_upload is not None):
|
32 |
warn_output = (
|