Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -3,9 +3,13 @@ import warnings
|
|
3 |
import torch
|
4 |
from transformers import WhisperTokenizer, WhisperForConditionalGeneration, WhisperProcessor
|
5 |
import soundfile as sf
|
|
|
6 |
|
7 |
warnings.filterwarnings("ignore")
|
8 |
|
|
|
|
|
|
|
9 |
# Load tokenizer and model
|
10 |
tokenizer = WhisperTokenizer.from_pretrained("NbAiLabBeta/nb-whisper-medium")
|
11 |
model = WhisperForConditionalGeneration.from_pretrained("NbAiLabBeta/nb-whisper-medium")
|
@@ -15,6 +19,7 @@ processor = WhisperProcessor.from_pretrained("NbAiLabBeta/nb-whisper-medium")
|
|
15 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
16 |
torch_dtype = torch.float32
|
17 |
|
|
|
18 |
def transcribe_audio(audio_file):
|
19 |
audio_input, _ = sf.read(audio_file)
|
20 |
inputs = processor(audio_input, sampling_rate=16000, return_tensors="pt")
|
@@ -50,4 +55,4 @@ with iface:
|
|
50 |
transcribe_button.click(fn=transcribe_audio, inputs=audio_input, outputs=transcription_output)
|
51 |
|
52 |
# Launch the interface
|
53 |
-
iface.launch(share=True, debug=True)
|
|
|
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 |
+
# Ensure you are logged in to Huggingface Hub
|
11 |
+
login(token="your_huggingface_token")
|
12 |
+
|
13 |
# Load tokenizer and model
|
14 |
tokenizer = WhisperTokenizer.from_pretrained("NbAiLabBeta/nb-whisper-medium")
|
15 |
model = WhisperForConditionalGeneration.from_pretrained("NbAiLabBeta/nb-whisper-medium")
|
|
|
19 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
20 |
torch_dtype = torch.float32
|
21 |
|
22 |
+
@spaces.GPU
|
23 |
def transcribe_audio(audio_file):
|
24 |
audio_input, _ = sf.read(audio_file)
|
25 |
inputs = processor(audio_input, sampling_rate=16000, return_tensors="pt")
|
|
|
55 |
transcribe_button.click(fn=transcribe_audio, inputs=audio_input, outputs=transcription_output)
|
56 |
|
57 |
# Launch the interface
|
58 |
+
iface.launch(share=True, debug=True)
|