barbaroo commited on
Commit
68a9c43
1 Parent(s): 6aaee7d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -1
app.py CHANGED
@@ -1,9 +1,20 @@
1
  import gradio as gr
2
  import time
3
  from transformers import pipeline
 
4
 
5
- p = pipeline("automatic-speech-recognition",
 
 
 
 
 
 
 
 
 
6
  model="carlosdanielhernandezmena/wav2vec2-large-xlsr-53-faroese-100h")
 
7
 
8
  def transcribe(audio, state="", uploaded_audio=None):
9
  if uploaded_audio is not None:
 
1
  import gradio as gr
2
  import time
3
  from transformers import pipeline
4
+ import torch
5
 
6
+ # Check if GPU is available
7
+ use_gpu = torch.cuda.is_available()
8
+
9
+
10
+ # Configure the pipeline to use the GPU if available
11
+ if use_gpu:
12
+ p = pipeline("automatic-speech-recognition",
13
+ model="carlosdanielhernandezmena/wav2vec2-large-xlsr-53-faroese-100h", device=0)
14
+ else:
15
+ p = pipeline("automatic-speech-recognition",
16
  model="carlosdanielhernandezmena/wav2vec2-large-xlsr-53-faroese-100h")
17
+
18
 
19
  def transcribe(audio, state="", uploaded_audio=None):
20
  if uploaded_audio is not None: