radinhas commited on
Commit
35706f8
1 Parent(s): 69f3571

Update apis/chat_api.py

Browse files
Files changed (1) hide show
  1. 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, item:WhisperPostItem):
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 item.model in MODEL_MAP.keys():
166
- target_model = item.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=item.lang, task="transcribe")
180
- text = pipe(item.audio_file)["text"]
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,