Update README.md
Browse files
README.md
CHANGED
@@ -28,12 +28,14 @@ if __name__ == '__main__':
|
|
28 |
print(f'usage: {argv[0]} <model> <file 1>')
|
29 |
exit(1)
|
30 |
|
|
|
|
|
31 |
processor = Wav2Vec2Processor.from_pretrained(argv[1])
|
32 |
-
model = Wav2Vec2ForCTC.from_pretrained(argv[1])
|
33 |
|
34 |
f = argv[2]
|
35 |
s,sample_rate = sf.read(f)
|
36 |
-
input_values = processor(s, return_tensors="pt").input_values
|
37 |
logits = model(input_values).logits
|
38 |
predicted_ids = torch.argmax(logits, dim=-1)
|
39 |
|
|
|
28 |
print(f'usage: {argv[0]} <model> <file 1>')
|
29 |
exit(1)
|
30 |
|
31 |
+
device = "cpu"
|
32 |
+
|
33 |
processor = Wav2Vec2Processor.from_pretrained(argv[1])
|
34 |
+
model = Wav2Vec2ForCTC.from_pretrained(argv[1]).to(device)
|
35 |
|
36 |
f = argv[2]
|
37 |
s,sample_rate = sf.read(f)
|
38 |
+
input_values = processor(s, return_tensors="pt").to(device).input_values
|
39 |
logits = model(input_values).logits
|
40 |
predicted_ids = torch.argmax(logits, dim=-1)
|
41 |
|