Skip to content

Commit

Permalink
Fixed websocket connection issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Emperor committed Jun 27, 2024
1 parent 5cb73a1 commit 9f77924
Show file tree
Hide file tree
Showing 7 changed files with 15,232 additions and 11,552 deletions.
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
script-shell=bash
10 changes: 6 additions & 4 deletions backend/demo_web_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
import socketio
from aiohttp import web

from backend.settings import BACKEND_PORT
from settings import BACKEND_PORT
from google_speech_wrapper import GoogleSpeechWrapper

app = web.Application()
sio = socketio.AsyncServer(cors_allowed_origins=[]) # * is bad
sio = socketio.AsyncServer(cors_allowed_origins=["http://localhost:3000"]) # * is bad

# Binds our Socket.IO server to our web app instance
sio.attach(app)


@asyncio.coroutine
@sio.on('startGoogleCloudStream')
async def start_google_stream(sid, config):
print(f'Starting streaming audio data from client {sid}')
Expand All @@ -31,4 +30,7 @@ async def close_google_stream(sid):
await GoogleSpeechWrapper.stop_recognition_stream(sid)


web.run_app(app, port=BACKEND_PORT)
if __name__ == "__main__":
web.run_app(app, port=BACKEND_PORT)


2 changes: 1 addition & 1 deletion backend/google_speech_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from google.cloud import speech

from backend.settings import GOOGLE_SERVICE_JSON_FILE
from settings import GOOGLE_SERVICE_JSON_FILE

clients = {}

Expand Down
2 changes: 2 additions & 0 deletions backend/settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import os

os.environ['GOOGLE_SERVICE_JSON_FILE'] = '../../speech-to-text-427711.json'

GOOGLE_SERVICE_JSON_FILE = os.environ['GOOGLE_SERVICE_JSON_FILE']
BACKEND_PORT = 10000
Loading

0 comments on commit 9f77924

Please sign in to comment.