Skip to content

Instantly share code, notes, and snippets.

@Vaibhavs10
Last active November 21, 2023 13:41
Show Gist options
  • Save Vaibhavs10/312c1136d5a587e2f06ef645e5d44a4d to your computer and use it in GitHub Desktop.
Save Vaibhavs10/312c1136d5a587e2f06ef645e5d44a4d to your computer and use it in GitHub Desktop.
import json
import time
import torch
from transformers import pipeline
pipe = pipeline(
"automatic-speech-recognition",
"openai/whisper-large-v3",
torch_dtype=torch.float16,
device="mps",
)
start = time.time()
output = pipe(
"https://huggingface.co/datasets/reach-vb/random-audios/resolve/main/ted_60.wav",
chunk_length_s=30,
batch_size=24,
return_timestamps=True,
)
end = time.time()
print("Total time!")
print(end - start)
with open("output.json", "w", encoding="utf8") as fp:
json.dump(output, fp, ensure_ascii=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment