AskYourVideo / utils /speech_recognition.py
MRuslanR's picture
Changed base prompt for Qwen
14183ba
raw
history blame contribute delete
412 Bytes
import torch
from transformers import pipeline
def transcribe_audio(audio_path):
device = "cpu"
if torch.cuda.is_available():
device = "cuda"
pipe = pipeline(
"automatic-speech-recognition",
model="openai/whisper-small",
device=device,
chunk_length_s=30,
)
return pipe(
audio_path,
batch_size=8,
return_timestamps=True
)