Spaces:
Running
Running
Update apis/chat_api.py
Browse files- apis/chat_api.py +5 -5
apis/chat_api.py
CHANGED
@@ -155,15 +155,15 @@ class ChatAPIApp:
|
|
155 |
audio_file: UploadFile = File(
|
156 |
description="Source Audio File",
|
157 |
)
|
158 |
-
def whisper_transcribe(self,
|
159 |
MODEL_MAP = {
|
160 |
"whisper-small": "openai/whisper-small",
|
161 |
"whisper-medium": "openai/whisper-medium",
|
162 |
"whisper-large": "openai/whisper-large",
|
163 |
"default": "openai/whisper-small",
|
164 |
}
|
165 |
-
if
|
166 |
-
target_model =
|
167 |
else:
|
168 |
target_model = "default"
|
169 |
|
@@ -176,8 +176,8 @@ class ChatAPIApp:
|
|
176 |
device=device,
|
177 |
)
|
178 |
time_start = time.time()
|
179 |
-
pipe.model.config.forced_decoder_ids = pipe.tokenizer.get_decoder_prompt_ids(language=
|
180 |
-
text = pipe(
|
181 |
time_end = time.time()
|
182 |
item_response = {
|
183 |
"statue": 200,
|
|
|
155 |
audio_file: UploadFile = File(
|
156 |
description="Source Audio File",
|
157 |
)
|
158 |
+
def whisper_transcribe(self, model:str = Field(default="whisper-small",description="(str) `Whisper model`"), lang:str = Field(default="en",description="(str) `transcribe to`"), audio_file: UploadFile = File(description="Source Audio File")):
|
159 |
MODEL_MAP = {
|
160 |
"whisper-small": "openai/whisper-small",
|
161 |
"whisper-medium": "openai/whisper-medium",
|
162 |
"whisper-large": "openai/whisper-large",
|
163 |
"default": "openai/whisper-small",
|
164 |
}
|
165 |
+
if model in MODEL_MAP.keys():
|
166 |
+
target_model = model
|
167 |
else:
|
168 |
target_model = "default"
|
169 |
|
|
|
176 |
device=device,
|
177 |
)
|
178 |
time_start = time.time()
|
179 |
+
pipe.model.config.forced_decoder_ids = pipe.tokenizer.get_decoder_prompt_ids(language=lang, task="transcribe")
|
180 |
+
text = pipe(audio_file)["text"]
|
181 |
time_end = time.time()
|
182 |
item_response = {
|
183 |
"statue": 200,
|