diff --git a/Dockerfile b/Dockerfile index 45c0c48..5df8a6a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,7 +19,7 @@ WORKDIR /app COPY . /app # Expose necessary ports -EXPOSE 8000 +EXPOSE 7200 # Command to run the script -CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "8000"] \ No newline at end of file +CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "7200"] \ No newline at end of file diff --git a/README.md b/README.md index ea06c88..7ac0b70 100644 --- a/README.md +++ b/README.md @@ -11,15 +11,15 @@ ### 1-DEVELOPMENT #### Run the system : Uvicorn and Fastapi - .venv/bin/uvicorn src.main:app --host 0.0.0.0 --port 8000 + .venv/bin/uvicorn src.main:app --host 0.0.0.0 --port 7200 ### 2-DEPLOYMENT #### Docker Build - docker build -t asr_farhang:latest --build-arg DEBIAN_FRONTEND=noninteractive . + docker build -t asr_farhang:latest . -#### Docker Run - docker run -d --gpus all --network host --restart unless-stopped asr_farhang:latest +#### Docker Run (port = 7200) + docker run -d --network host --restart unless-stopped asr_farhang:latest diff --git a/test/test.js b/test/test.js index 531cd08..21274b3 100644 --- a/test/test.js +++ b/test/test.js @@ -1,4 +1,4 @@ -const ws = new WebSocket("ws://localhost:8000/asr"); +const ws = new WebSocket("ws://localhost:7200/asr"); ws.onmessage = (event) => { console.log("ASR Result:", event.data); diff --git a/test/test.py b/test/test.py index 61e216b..f395142 100644 --- a/test/test.py +++ b/test/test.py @@ -2,26 +2,30 @@ import asyncio import websockets import json -AUDIO_FILE = "./khabar_1_5.wav" # Replace with your audio file path -WS_URL = "ws://127.0.0.1:8000/asr" +AUDIO_FILE = "./data/khabar_1_5.wav" +WS_URL = "ws://127.0.0.1:7200/asr" async def send_audio(): async with websockets.connect(WS_URL) as ws: print("Connected to ASR WebSocket") - # Read the audio file in chunks + # Send audio in chunks with open(AUDIO_FILE, "rb") as f: - chunk_size = 21920 + chunk_size = 100000 while chunk := f.read(chunk_size): await ws.send(chunk) - + + # Tell server no more audio is coming + await ws.send(json.dumps({"eof": True})) + + # Receive results try: while True: message = await ws.recv() data = json.loads(message) print("Received:", data) + except websockets.exceptions.ConnectionClosed: print("WebSocket closed by server") -# Run the async client asyncio.run(send_audio())