Sofia Casadei commited on
Commit
ea07abc
Β·
1 Parent(s): a0a0448

ft: run locally via Docker

Browse files
Files changed (3) hide show
  1. .gitignore +4 -1
  2. docker-compose.yml +14 -0
  3. main.py +6 -2
.gitignore CHANGED
@@ -1 +1,4 @@
1
- __pycache__/
 
 
 
 
1
+ __pycache__/
2
+ logs/
3
+ .env
4
+ .venv/
docker-compose.yml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: '3'
2
+
3
+ services:
4
+ app:
5
+ build:
6
+ context: .
7
+ dockerfile: Dockerfile
8
+ ports:
9
+ - "7860:7860"
10
+ volumes:
11
+ - ./:/app
12
+ restart: unless-stopped
13
+ env_file: .env
14
+ command: uvicorn main:app --host 0.0.0.0 --port 7860
main.py CHANGED
@@ -17,7 +17,6 @@ from fastrtc import (
17
  AlgoOptions,
18
  SileroVadOptions,
19
  audio_to_bytes,
20
- get_cloudflare_turn_credentials,
21
  get_cloudflare_turn_credentials_async,
22
  )
23
  from transformers import (
@@ -152,6 +151,7 @@ async def index():
152
  html_content = open("static/index-screen.html").read()
153
 
154
  rtc_configuration = await get_cloudflare_turn_credentials_async(hf_token=os.getenv("HF_TOKEN")) if APP_MODE == "deployed" else None
 
155
  html_content = html_content.replace("__RTC_CONFIGURATION__", json.dumps(rtc_configuration))
156
  return HTMLResponse(content=html_content)
157
 
@@ -168,4 +168,8 @@ def _(webrtc_id: str):
168
  logger.error(f"Error in transcript stream for {webrtc_id}: {str(e)}")
169
  raise
170
 
171
- return StreamingResponse(output_stream(), media_type="text/event-stream")
 
 
 
 
 
17
  AlgoOptions,
18
  SileroVadOptions,
19
  audio_to_bytes,
 
20
  get_cloudflare_turn_credentials_async,
21
  )
22
  from transformers import (
 
151
  html_content = open("static/index-screen.html").read()
152
 
153
  rtc_configuration = await get_cloudflare_turn_credentials_async(hf_token=os.getenv("HF_TOKEN")) if APP_MODE == "deployed" else None
154
+ logger.info(f"RTC configuration: {rtc_configuration}")
155
  html_content = html_content.replace("__RTC_CONFIGURATION__", json.dumps(rtc_configuration))
156
  return HTMLResponse(content=html_content)
157
 
 
168
  logger.error(f"Error in transcript stream for {webrtc_id}: {str(e)}")
169
  raise
170
 
171
+ return StreamingResponse(output_stream(), media_type="text/event-stream")
172
+
173
+ if __name__ == "__main__":
174
+ import uvicorn
175
+ uvicorn.run(app, host="localhost", port=7860)