Spaces:
Build error
Build error
camparchimedes
commited on
Commit
•
f9cd637
1
Parent(s):
5c56ed6
Update app.py
Browse files
app.py
CHANGED
@@ -3,22 +3,22 @@ import warnings
|
|
3 |
import torch
|
4 |
from transformers import WhisperTokenizer, WhisperForConditionalGeneration, WhisperProcessor
|
5 |
import soundfile as sf
|
6 |
-
from huggingface_hub import login
|
7 |
|
8 |
warnings.filterwarnings("ignore")
|
9 |
|
10 |
-
|
11 |
-
# tokenizer, model
|
12 |
tokenizer = WhisperTokenizer.from_pretrained("NbAiLabBeta/nb-whisper-medium")
|
13 |
model = WhisperForConditionalGeneration.from_pretrained("NbAiLabBeta/nb-whisper-medium")
|
14 |
processor = WhisperProcessor.from_pretrained("NbAiLabBeta/nb-whisper-medium")
|
15 |
|
16 |
-
#
|
17 |
-
device = ('cuda')
|
18 |
-
# device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
19 |
torch_dtype = torch.float32
|
|
|
|
|
20 |
model.to(device)
|
21 |
|
|
|
22 |
def transcribe_audio(audio_file):
|
23 |
audio_input, _ = sf.read(audio_file)
|
24 |
inputs = processor(audio_input, sampling_rate=16000, return_tensors="pt")
|
@@ -41,7 +41,7 @@ banner_html = """
|
|
41 |
</div>
|
42 |
"""
|
43 |
|
44 |
-
#
|
45 |
iface = gr.Blocks()
|
46 |
|
47 |
with iface:
|
|
|
3 |
import torch
|
4 |
from transformers import WhisperTokenizer, WhisperForConditionalGeneration, WhisperProcessor
|
5 |
import soundfile as sf
|
|
|
6 |
|
7 |
warnings.filterwarnings("ignore")
|
8 |
|
9 |
+
# Load tokenizer + model
|
|
|
10 |
tokenizer = WhisperTokenizer.from_pretrained("NbAiLabBeta/nb-whisper-medium")
|
11 |
model = WhisperForConditionalGeneration.from_pretrained("NbAiLabBeta/nb-whisper-medium")
|
12 |
processor = WhisperProcessor.from_pretrained("NbAiLabBeta/nb-whisper-medium")
|
13 |
|
14 |
+
# set up device
|
15 |
+
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
|
|
16 |
torch_dtype = torch.float32
|
17 |
+
|
18 |
+
# move model to device
|
19 |
model.to(device)
|
20 |
|
21 |
+
|
22 |
def transcribe_audio(audio_file):
|
23 |
audio_input, _ = sf.read(audio_file)
|
24 |
inputs = processor(audio_input, sampling_rate=16000, return_tensors="pt")
|
|
|
41 |
</div>
|
42 |
"""
|
43 |
|
44 |
+
# Gradio interface
|
45 |
iface = gr.Blocks()
|
46 |
|
47 |
with iface:
|