Michael Natanael commited on
Commit
57238f2
·
1 Parent(s): d5f46fd

change transcribe mechanism when uploading audio

Browse files
Files changed (2) hide show
  1. Dockerfile +1 -1
  2. app.py +6 -3
Dockerfile CHANGED
@@ -22,4 +22,4 @@ RUN pip install --no-cache-dir --upgrade -r requirements.txt
22
 
23
  COPY --chown=user . /app
24
  # CMD ["gunicorn", "-b", "0.0.0.0:7860", "app:app"]
25
- CMD ["gunicorn", "--timeout", "120", "-b", "0.0.0.0:7860", "app:app"]
 
22
 
23
  COPY --chown=user . /app
24
  # CMD ["gunicorn", "-b", "0.0.0.0:7860", "app:app"]
25
+ CMD ["gunicorn", "--timeout", "300", "--workers", "1", "--threads", "2", "-b", "0.0.0.0:7860", "app:app"]
app.py CHANGED
@@ -68,15 +68,18 @@ pipe = pipeline(
68
  model=whisper_model,
69
  tokenizer=processor.tokenizer,
70
  feature_extractor=processor.feature_extractor,
71
- chunk_length_s=10,
72
- batch_size=4, # batch size for inference - set based on your device
73
  torch_dtype=torch_dtype,
74
  device=device,
 
 
 
75
  )
76
 
77
 
78
  def whisper_api(temp_audio_path):
79
- result = pipe(temp_audio_path, return_timestamps=False, generate_kwargs={"language": "indonesian"})
80
  print(result["text"])
81
  return result
82
 
 
68
  model=whisper_model,
69
  tokenizer=processor.tokenizer,
70
  feature_extractor=processor.feature_extractor,
71
+ chunk_length_s=30,
72
+ batch_size=1, # batch size for inference - set based on your device
73
  torch_dtype=torch_dtype,
74
  device=device,
75
+ max_new_tokens=128, # Limit text generation
76
+ return_timestamps=False, # Save memory
77
+ device_map="auto", # Better resource handling
78
  )
79
 
80
 
81
  def whisper_api(temp_audio_path):
82
+ result = pipe(temp_audio_path, generate_kwargs={"language": "indonesian", "task": "transcribe"})
83
  print(result["text"])
84
  return result
85