Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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("
|
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
|
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]
|