Morgan Funtowicz commited on
Commit
d3df147
·
1 Parent(s): 177efa8

feat(whisper): expose interface and port customization for endpoint

Browse files
Files changed (2) hide show
  1. Dockerfile +3 -1
  2. handler.py +5 -1
Dockerfile CHANGED
@@ -7,7 +7,9 @@ RUN --mount=type=bind,from=huggingface/endpoints-sdk:v1.0.0-beta-py312-manylinux
7
 
8
  COPY endpoint.py /opt/endpoints/
9
 
10
- EXPOSE 8000
 
11
 
 
12
  ENTRYPOINT ["python3"]
13
  CMD ["/opt/endpoints/handler.py"]
 
7
 
8
  COPY endpoint.py /opt/endpoints/
9
 
10
+ ENV HFENDPOINT_INTERFACE 0.0.0.0
11
+ ENV HFENDPOINT_PORT 80
12
 
13
+ EXPOSE 80
14
  ENTRYPOINT ["python3"]
15
  CMD ["/opt/endpoints/handler.py"]
handler.py CHANGED
@@ -1,4 +1,5 @@
1
  import asyncio
 
2
  import zlib
3
  from functools import lru_cache
4
  from io import BytesIO
@@ -373,10 +374,13 @@ class WhisperHandler(Handler[TranscriptionRequest, TranscriptionResponse]):
373
 
374
 
375
  def entrypoint():
 
 
 
376
  endpoint = AutomaticSpeechRecognitionEndpoint(
377
  WhisperHandler("openai/whisper-large-v3")
378
  )
379
- run(endpoint, "0.0.0.0", 8000)
380
 
381
 
382
  if __name__ == "__main__":
 
1
  import asyncio
2
+ import os
3
  import zlib
4
  from functools import lru_cache
5
  from io import BytesIO
 
374
 
375
 
376
  def entrypoint():
377
+ interface = int(os.environ.get("HFENDPOINT_INTERFACE", "0.0.0.0"))
378
+ port = int(os.environ.get("HFENDPOINT_PORT", "8000"))
379
+
380
  endpoint = AutomaticSpeechRecognitionEndpoint(
381
  WhisperHandler("openai/whisper-large-v3")
382
  )
383
+ run(endpoint, interface, port)
384
 
385
 
386
  if __name__ == "__main__":