Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -59,7 +59,8 @@ if not torch.cuda.is_available():
|
|
59 |
raise RuntimeError("CUDA not available. Go look for a GPU.")
|
60 |
|
61 |
# Set GPU
|
62 |
-
|
|
|
63 |
|
64 |
def convert_to_wav(filepath):
|
65 |
_, file_ending = os.path.splitext(f'{filepath}')
|
@@ -67,7 +68,7 @@ def convert_to_wav(filepath):
|
|
67 |
os.system(f'ffmpeg -i "{filepath}" -ar 16000 -ac 1 -c:a pcm_s16le "{audio_file}"')
|
68 |
return audio_file
|
69 |
|
70 |
-
pipe = pipeline("automatic-speech-recognition", model="NbAiLab/nb-whisper-large", chunk_length_s=30,
|
71 |
|
72 |
def transcribe_audio(audio_file, batch_size=16):
|
73 |
start_time = time.time()
|
|
|
59 |
raise RuntimeError("CUDA not available. Go look for a GPU.")
|
60 |
|
61 |
# Set GPU
|
62 |
+
dtype = torch.bfloat32
|
63 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
64 |
|
65 |
def convert_to_wav(filepath):
|
66 |
_, file_ending = os.path.splitext(f'{filepath}')
|
|
|
68 |
os.system(f'ffmpeg -i "{filepath}" -ar 16000 -ac 1 -c:a pcm_s16le "{audio_file}"')
|
69 |
return audio_file
|
70 |
|
71 |
+
pipe = pipeline("automatic-speech-recognition", model="NbAiLab/nb-whisper-large", chunk_length_s=30, torch_dtype=dtype).to(device)
|
72 |
|
73 |
def transcribe_audio(audio_file, batch_size=16):
|
74 |
start_time = time.time()
|