Spaces:
Running
Running
File size: 1,007 Bytes
7aaf29c 28d0c5f 7aaf29c 28d0c5f 7aaf29c 28d0c5f 7aaf29c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
from typing import Any
import torch
import torch.nn as nn
# second returned type here is the custom class src.silero.utils.Decoder from snakers4/silero-models
def getASRModel(language: str) -> tuple[nn.Module, Any]:
if language == 'de':
model, decoder, utils = torch.hub.load(repo_or_dir='snakers4/silero-models',
model='silero_stt',
language='de',
device=torch.device('cpu'))
elif language == 'en':
model, decoder, utils = torch.hub.load(repo_or_dir='snakers4/silero-models',
model='silero_stt',
language='en',
device=torch.device('cpu'))
else:
raise NotImplementedError("currenty works only for 'de' and 'en' languages, not for '{}'.".format(language))
return model, decoder
|