Spaces:
Running
on
T4
Running
on
T4
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,6 +4,7 @@ import torch
|
|
| 4 |
|
| 5 |
import gradio as gr
|
| 6 |
import pytube as pt
|
|
|
|
| 7 |
from transformers import pipeline
|
| 8 |
from huggingface_hub import model_info
|
| 9 |
|
|
@@ -13,6 +14,7 @@ lang = "fi"
|
|
| 13 |
share = (os.environ.get("SHARE", "False")[0].lower() in "ty1") or None
|
| 14 |
auth_token = os.environ.get("AUTH_TOKEN") or True
|
| 15 |
device = 0 if torch.cuda.is_available() else "cpu"
|
|
|
|
| 16 |
pipe = pipeline(
|
| 17 |
task="automatic-speech-recognition",
|
| 18 |
model=MODEL_NAME,
|
|
@@ -23,6 +25,7 @@ pipe = pipeline(
|
|
| 23 |
|
| 24 |
pipe.model.config.forced_decoder_ids = pipe.tokenizer.get_decoder_prompt_ids(language=lang, task="transcribe")
|
| 25 |
|
|
|
|
| 26 |
def transcribe(microphone, file_upload):
|
| 27 |
warn_output = ""
|
| 28 |
if (microphone is not None) and (file_upload is not None):
|
|
|
|
| 4 |
|
| 5 |
import gradio as gr
|
| 6 |
import pytube as pt
|
| 7 |
+
import spaces
|
| 8 |
from transformers import pipeline
|
| 9 |
from huggingface_hub import model_info
|
| 10 |
|
|
|
|
| 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("Using device: {device}")
|
| 18 |
pipe = pipeline(
|
| 19 |
task="automatic-speech-recognition",
|
| 20 |
model=MODEL_NAME,
|
|
|
|
| 25 |
|
| 26 |
pipe.model.config.forced_decoder_ids = pipe.tokenizer.get_decoder_prompt_ids(language=lang, task="transcribe")
|
| 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):
|