Spaces:
Runtime error
Runtime error
File size: 966 Bytes
b89343f 1d6a66d b89343f 1d6a66d b89343f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="scb10x/llama-3-typhoon-v1.5-8b-audio-preview", trust_remote_code=True)
from transformers import AutoModel
# Initialize from the trained model
model = AutoModel.from_pretrained(
"scb10x/llama-3-typhoon-v1.5-8b-audio-preview",
torch_dtype=torch.float16,
trust_remote_code=True
)
model.to("cuda")
model.eval()
# Run generation
prompt_pattern="<|begin_of_text|><|start_header_id|>user<|end_header_id|>\n\n<Speech><SpeechHere></Speech> {}<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n"
response = model.generate(
wav_path="path_to_your_audio.wav",
prompt="transcribe this audio",
prompt_pattern=prompt_pattern,
do_sample=False,
max_length=1200,
repetition_penalty=1.1,
num_beams=1,
# temperature=0.4,
# top_p=0.9,
# streamer=streamer # supports TextIteratorStreamer
)
print(response)
|