Skip to content

Commit

Permalink
Update inference.py
Browse files Browse the repository at this point in the history
  • Loading branch information
sooftware authored Aug 14, 2022
1 parent cfb7db2 commit 3b5a9e9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions bin/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def parse_audio(audio_path: str, del_silence: bool = False, audio_extension: str


parser = argparse.ArgumentParser(description='KoSpeech')
parser.add_argument('--model_path', type=str, require=True)
parser.add_argument('--audio_path', type=str, require=True)
parser.add_argument('--model_path', type=str, required=True)
parser.add_argument('--audio_path', type=str, required=True)
parser.add_argument('--device', type=str, require=False, default='cpu')
opt = parser.parse_args()

Expand All @@ -65,12 +65,12 @@ def parse_audio(audio_path: str, del_silence: bool = False, audio_extension: str
model.encoder.device = opt.device
model.decoder.device = opt.device

y_hats = model.greedy_search(feature.unsqueeze(0), input_length, opt.device)
y_hats = model.recognize(feature.unsqueeze(0), input_length)
elif isinstance(model, DeepSpeech2):
model.device = opt.device
y_hats = model.greedy_search(feature.unsqueeze(0), input_length, opt.device)
y_hats = model.recognize(feature.unsqueeze(0), input_length)
elif isinstance(model, SpeechTransformer) or isinstance(model, Jasper) or isinstance(model, Conformer):
y_hats = model.greedy_search(feature.unsqueeze(0), input_length, opt.device)
y_hats = model.recognize(feature.unsqueeze(0), input_length)

sentence = vocab.label_to_string(y_hats.cpu().detach().numpy())
print(sentence)

0 comments on commit 3b5a9e9

Please sign in to comment.