Instructions to use web30india/LLM-GUJARATI with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use web30india/LLM-GUJARATI with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("automatic-speech-recognition", model="web30india/LLM-GUJARATI")# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForSpeechSeq2Seq processor = AutoProcessor.from_pretrained("web30india/LLM-GUJARATI") model = AutoModelForSpeechSeq2Seq.from_pretrained("web30india/LLM-GUJARATI", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download api.py from web30india/LLM-GUJARATI: direct link, hf CLI and curl.
- Browser
- Download file 1.26 kB
-
https://huggingface.co/web30india/LLM-GUJARATI/resolve/main/api.py
- Command line
-
hf download hf://web30india/LLM-GUJARATI/api.py
-
curl -L -o api.py https://huggingface.co/web30india/LLM-GUJARATI/resolve/main/api.py
1.26 kB
| from flask import Flask, request, jsonify | |
| from transformers import pipeline | |
| import torch | |
| app = Flask(__name__) | |
| def init_transcription_pipeline(): | |
| device = "cuda:0" if torch.cuda.is_available() else "cpu" | |
| model_path = "c:/Users/vhits/Documents/Speect2Text/model/whisper-gujarati-medium" | |
| transcribe_pipeline = pipeline( | |
| task = "automatic-speech-recognition", | |
| model = model_path, | |
| chunk_length_s = 30, | |
| device = device | |
| ) | |
| transcribe_pipeline.model.config.forced_decoder_ids = transcribe_pipeline.tokenizer.get_decoder_prompt_ids(language="gu", task="transcribe") | |
| return transcribe_pipeline | |
| transcribe_pipeline = init_transcription_pipeline() | |
| def transcribe_audio(): | |
| if 'audio_file' not in request.files: | |
| return jsonify({"error": "No file part"}), 400 | |
| file = request.files['audio_file'] | |
| if file.filename == '': | |
| return jsonify({"error": "No selected file"}), 400 | |
| if file: | |
| transcription_result = transcribe_pipeline(file)["text"] | |
| return jsonify({"transcription": transcription_result}) | |
| return jsonify({"error": "An error occurred during transcription"}), 500 | |
| if __name__ == '__main__': | |
| app.run(debug=True) | |