radinhas commited on
Commit
91fabe4
1 Parent(s): 35706f8

Update apis/chat_api.py

Browse files
Files changed (1) hide show
  1. 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, 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",
@@ -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,