Simonlob commited on
Commit
6660ce2
1 Parent(s): f502d04

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -8,14 +8,14 @@ import re
8
 
9
  processor = Wav2Vec2Processor.from_pretrained("the-cramer-project/Wav2vec-Kyrgyz")
10
  model = Wav2Vec2ForCTC.from_pretrained("the-cramer-project/Wav2vec-Kyrgyz")
11
- model.to("cpu") #.to("cuda")
12
 
13
  def transcribe(file_):
14
  arr_audio, _ = librosa.load(file_, sr=16000)
15
  inputs = processor(arr_audio, sampling_rate=16_000, return_tensors="pt", padding=True)
16
 
17
  with torch.no_grad():
18
- logits = model(inputs.input_values, attention_mask=inputs.attention_mask).logits #model(inputs.input_values.to("cuda"), attention_mask=inputs.attention_mask.to("cuda")).logits
19
 
20
  pred_ids = torch.argmax(logits, dim=-1)
21
  text = processor.batch_decode(pred_ids)[0]
 
8
 
9
  processor = Wav2Vec2Processor.from_pretrained("the-cramer-project/Wav2vec-Kyrgyz")
10
  model = Wav2Vec2ForCTC.from_pretrained("the-cramer-project/Wav2vec-Kyrgyz")
11
+ model.to("cuda")
12
 
13
  def transcribe(file_):
14
  arr_audio, _ = librosa.load(file_, sr=16000)
15
  inputs = processor(arr_audio, sampling_rate=16_000, return_tensors="pt", padding=True)
16
 
17
  with torch.no_grad():
18
+ logits = model(inputs.input_values.to("cuda"), attention_mask=inputs.attention_mask.to("cuda")).logits
19
 
20
  pred_ids = torch.argmax(logits, dim=-1)
21
  text = processor.batch_decode(pred_ids)[0]