Spaces:
Running
Running
Update apis/chat_api.py
Browse files- apis/chat_api.py +5 -5
apis/chat_api.py
CHANGED
@@ -153,9 +153,9 @@ class ChatAPIApp:
|
|
153 |
description="(str) `transcribe to`",
|
154 |
)
|
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",
|
@@ -163,7 +163,7 @@ class ChatAPIApp:
|
|
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,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=lang, task="transcribe")
|
180 |
-
text = pipe(audio_file)["text"]
|
181 |
time_end = time.time()
|
182 |
item_response = {
|
183 |
"statue": 200,
|
|
|
153 |
description="(str) `transcribe to`",
|
154 |
)
|
155 |
audio_file: UploadFile = File(
|
156 |
+
description="(File) `Source Audio File`",
|
157 |
)
|
158 |
+
def whisper_transcribe(self, item:WhisperPostItem):
|
159 |
MODEL_MAP = {
|
160 |
"whisper-small": "openai/whisper-small",
|
161 |
"whisper-medium": "openai/whisper-medium",
|
|
|
163 |
"default": "openai/whisper-small",
|
164 |
}
|
165 |
if model in MODEL_MAP.keys():
|
166 |
+
target_model = item.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=item.lang, task="transcribe")
|
180 |
+
text = pipe(item.audio_file)["text"]
|
181 |
time_end = time.time()
|
182 |
item_response = {
|
183 |
"statue": 200,
|