Spaces:
Sleeping
Sleeping
Download libs/transformer/get_transcript_2.py from minhpng/test_python: direct link, hf CLI and curl.
- Browser
- Download file 347 Bytes
-
https://huggingface.co/spaces/minhpng/test_python/resolve/main/libs/transformer/get_transcript_2.py
- Command line
-
hf download hf://spaces/minhpng/test_python/libs/transformer/get_transcript_2.py
-
curl -L -o get_transcript_2.py https://huggingface.co/spaces/minhpng/test_python/resolve/main/libs/transformer/get_transcript_2.py
347 Bytes
| import torch | |
| from transformers import pipeline | |
| def get_transcribe_transformers(url:str, model: str): | |
| device = "cuda:0" if torch.cuda.is_available() else "cpu" | |
| pipe = pipeline("automatic-speech-recognition", model=model, return_timestamps=True, device=device) | |
| result = pipe(url) | |
| return result.get("text"), result.get("chunks") | |