Spaces:
Running
Running
from faster_whisper import WhisperModel | |
import torch | |
device = "cuda" if torch.cuda.is_available() else "cpu" | |
torch_dtype = "float32" | |
MODEL_NAME = "Systran/faster-whisper-large-v3" | |
model = WhisperModel(MODEL_NAME, compute_type=torch_dtype) | |
def generate(audio_path): | |
#check audio lenght | |
segments, _ = model.transcribe( | |
audio_path, | |
# language="ca", | |
# chunk_length=30, | |
task="transcribe", | |
word_timestamps=False, | |
) | |
text = "" | |
for segment in segments: | |
text += " " + segment.text.strip() | |
return text | |