Update handler.py
Browse files- handler.py +2 -1
handler.py
CHANGED
|
@@ -4,11 +4,12 @@ import torch
|
|
| 4 |
from transformers.pipelines.audio_utils import ffmpeg_read
|
| 5 |
|
| 6 |
#ffmpeg
|
|
|
|
| 7 |
|
| 8 |
|
| 9 |
class EndpointHandler:
|
| 10 |
def __init__(self, path=""):
|
| 11 |
-
self.pipe = pipeline(task='automatic-speech-recognition', model=path)
|
| 12 |
|
| 13 |
def __call__(self, data: Any) -> List[Dict[str, str]]:
|
| 14 |
|
|
|
|
| 4 |
from transformers.pipelines.audio_utils import ffmpeg_read
|
| 5 |
|
| 6 |
#ffmpeg
|
| 7 |
+
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
| 8 |
|
| 9 |
|
| 10 |
class EndpointHandler:
|
| 11 |
def __init__(self, path=""):
|
| 12 |
+
self.pipe = pipeline(task='automatic-speech-recognition', model=path, device=device)
|
| 13 |
|
| 14 |
def __call__(self, data: Any) -> List[Dict[str, str]]:
|
| 15 |
|