port 7200
This commit is contained in:
parent
fe8031122a
commit
4fd908918d
@ -19,7 +19,7 @@ WORKDIR /app
|
|||||||
COPY . /app
|
COPY . /app
|
||||||
|
|
||||||
# Expose necessary ports
|
# Expose necessary ports
|
||||||
EXPOSE 8000
|
EXPOSE 7200
|
||||||
|
|
||||||
# Command to run the script
|
# Command to run the script
|
||||||
CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "8000"]
|
CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "7200"]
|
||||||
@ -11,15 +11,15 @@
|
|||||||
|
|
||||||
### 1-DEVELOPMENT
|
### 1-DEVELOPMENT
|
||||||
#### Run the system : Uvicorn and Fastapi
|
#### 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
|
### 2-DEPLOYMENT
|
||||||
#### Docker Build
|
#### Docker Build
|
||||||
docker build -t asr_farhang:latest --build-arg DEBIAN_FRONTEND=noninteractive .
|
docker build -t asr_farhang:latest .
|
||||||
|
|
||||||
|
|
||||||
#### Docker Run
|
#### Docker Run (port = 7200)
|
||||||
docker run -d --gpus all --network host --restart unless-stopped asr_farhang:latest
|
docker run -d --network host --restart unless-stopped asr_farhang:latest
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
const ws = new WebSocket("ws://localhost:8000/asr");
|
const ws = new WebSocket("ws://localhost:7200/asr");
|
||||||
|
|
||||||
ws.onmessage = (event) => {
|
ws.onmessage = (event) => {
|
||||||
console.log("ASR Result:", event.data);
|
console.log("ASR Result:", event.data);
|
||||||
|
|||||||
16
test/test.py
16
test/test.py
@ -2,26 +2,30 @@ import asyncio
|
|||||||
import websockets
|
import websockets
|
||||||
import json
|
import json
|
||||||
|
|
||||||
AUDIO_FILE = "./khabar_1_5.wav" # Replace with your audio file path
|
AUDIO_FILE = "./data/khabar_1_5.wav"
|
||||||
WS_URL = "ws://127.0.0.1:8000/asr"
|
WS_URL = "ws://127.0.0.1:7200/asr"
|
||||||
|
|
||||||
async def send_audio():
|
async def send_audio():
|
||||||
async with websockets.connect(WS_URL) as ws:
|
async with websockets.connect(WS_URL) as ws:
|
||||||
print("Connected to ASR WebSocket")
|
print("Connected to ASR WebSocket")
|
||||||
|
|
||||||
# Read the audio file in chunks
|
# Send audio in chunks
|
||||||
with open(AUDIO_FILE, "rb") as f:
|
with open(AUDIO_FILE, "rb") as f:
|
||||||
chunk_size = 21920
|
chunk_size = 100000
|
||||||
while chunk := f.read(chunk_size):
|
while chunk := f.read(chunk_size):
|
||||||
await ws.send(chunk)
|
await ws.send(chunk)
|
||||||
|
|
||||||
|
# Tell server no more audio is coming
|
||||||
|
await ws.send(json.dumps({"eof": True}))
|
||||||
|
|
||||||
|
# Receive results
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
message = await ws.recv()
|
message = await ws.recv()
|
||||||
data = json.loads(message)
|
data = json.loads(message)
|
||||||
print("Received:", data)
|
print("Received:", data)
|
||||||
|
|
||||||
except websockets.exceptions.ConnectionClosed:
|
except websockets.exceptions.ConnectionClosed:
|
||||||
print("WebSocket closed by server")
|
print("WebSocket closed by server")
|
||||||
|
|
||||||
# Run the async client
|
|
||||||
asyncio.run(send_audio())
|
asyncio.run(send_audio())
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user