Download usage.py from datasetsANDmodels/language-identification: direct link, hf CLI and curl.
- Browser
- Download file 365 Bytes
-
https://huggingface.co/datasetsANDmodels/language-identification/resolve/main/usage.py
- Command line
-
hf download hf://datasetsANDmodels/language-identification/usage.py
-
curl -L -o usage.py https://huggingface.co/datasetsANDmodels/language-identification/resolve/main/usage.py
365 Bytes
| import sys | |
| from transformers import pipeline | |
| audio_file_path = sys.argv[1] | |
| model_name="language-identification" | |
| pipe = pipeline("automatic-speech-recognition", model=model_name, return_language=True) | |
| result = pipe(audio_file_path,generate_kwargs={"task": "transcribe"}) | |
| transcript=result["text"] | |
| language= result['chunks'][0]['language'] | |
| print ( language ) | |