Views
No views yet
namaste, aap kaise hain?1import torch
2from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor, pipeline
3
4device = "cuda:0" if torch.cuda.is_available() else "cpu"
5torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
6
7model_id = "Svetozar1993/HindiSTT"
8
9model = AutoModelForSpeechSeq2Seq.from_pretrained(
10 model_id,
11 torch_dtype=torch_dtype,
12 low_cpu_mem_usage=True,
13 use_safetensors=True
14)
15model.to(device)
16
17processor = AutoProcessor.from_pretrained(model_id)
18
19pipe = pipeline(
20 "automatic-speech-recognition",
21 model=model,
22 tokenizer=processor.tokenizer,
23 feature_extractor=processor.feature_extractor,
24 torch_dtype=torch_dtype,
25 device=device,
26 generate_kwargs={"task": "transcribe", "language": "en"}
27)
28
29result = pipe("audio.wav")
30print(result["text"])pip install flash-attn --no-build-isolation1model = AutoModelForSpeechSeq2Seq.from_pretrained(
2 model_id,
3 torch_dtype=torch_dtype,
4 low_cpu_mem_usage=True,
5 attn_implementation="flash_attention_2"
6)