Update app.py
Browse files
app.py
CHANGED
@@ -112,40 +112,6 @@ def transcribe(audio_filepath, src_lang, tgt_lang, pnc):
|
|
112 |
output_text = hyps[0].text
|
113 |
|
114 |
return output_text
|
115 |
-
|
116 |
-
import torch
|
117 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
118 |
-
|
119 |
-
torch.random.manual_seed(0)
|
120 |
-
|
121 |
-
model = AutoModelForCausalLM.from_pretrained(
|
122 |
-
"microsoft/Phi-3-mini-128k-instruct",
|
123 |
-
device_map="auto",
|
124 |
-
torch_dtype="auto",
|
125 |
-
trust_remote_code=True,
|
126 |
-
)
|
127 |
-
tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-3-mini-128k-instruct")
|
128 |
-
|
129 |
-
messages = [
|
130 |
-
{"role": "user", "content": str(output_text)},
|
131 |
-
]
|
132 |
-
|
133 |
-
pipe = pipeline(
|
134 |
-
"text-generation",
|
135 |
-
model=model,
|
136 |
-
tokenizer=tokenizer,
|
137 |
-
)
|
138 |
-
|
139 |
-
generation_args = {
|
140 |
-
"max_new_tokens": 500,
|
141 |
-
"return_full_text": True,
|
142 |
-
"temperature": 0.0,
|
143 |
-
"do_sample": False,
|
144 |
-
}
|
145 |
-
|
146 |
-
output_text = pipe(messages, **generation_args)
|
147 |
-
print(output[0]['generated_text'])
|
148 |
-
|
149 |
|
150 |
with gr.Blocks(
|
151 |
title="myAlexa",
|
|
|
112 |
output_text = hyps[0].text
|
113 |
|
114 |
return output_text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
|
116 |
with gr.Blocks(
|
117 |
title="myAlexa",
|