Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,32 @@
|
|
| 1 |
-
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use a pipeline as a high-level helper
|
| 2 |
+
from transformers import pipeline
|
| 3 |
|
| 4 |
+
pipe = pipeline("text-generation", model="scb10x/llama-3-typhoon-v1.5-8b-audio-preview", trust_remote_code=True)
|
| 5 |
|
| 6 |
+
|
| 7 |
+
from transformers import AutoModel
|
| 8 |
+
|
| 9 |
+
# Initialize from the trained model
|
| 10 |
+
model = AutoModel.from_pretrained(
|
| 11 |
+
"scb10x/llama-3-typhoon-v1.5-8b-audio-preview",
|
| 12 |
+
torch_dtype=torch.float16,
|
| 13 |
+
trust_remote_code=True
|
| 14 |
+
)
|
| 15 |
+
model.to("cuda")
|
| 16 |
+
model.eval()
|
| 17 |
+
|
| 18 |
+
# Run generation
|
| 19 |
+
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"
|
| 20 |
+
response = model.generate(
|
| 21 |
+
wav_path="path_to_your_audio.wav",
|
| 22 |
+
prompt="transcribe this audio",
|
| 23 |
+
prompt_pattern=prompt_pattern,
|
| 24 |
+
do_sample=False,
|
| 25 |
+
max_length=1200,
|
| 26 |
+
repetition_penalty=1.1,
|
| 27 |
+
num_beams=1,
|
| 28 |
+
# temperature=0.4,
|
| 29 |
+
# top_p=0.9,
|
| 30 |
+
# streamer=streamer # supports TextIteratorStreamer
|
| 31 |
+
)
|
| 32 |
+
print(response)
|