Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in connection handler #253

Open
Nollknolle opened this issue Jun 17, 2024 · 0 comments
Open

Error in connection handler #253

Nollknolle opened this issue Jun 17, 2024 · 0 comments

Comments

@Nollknolle
Copy link

I get the following error with this python code:

INFO:root:Connection from ('xx.xx.xxx.xxx', 63393)
INFO:root:Config {'sample_rate': 16000}
ERROR:websockets.server:Error in connection handler
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/websockets/server.py", line 191, in handler
await self.ws_handler(self, path)
File "/opt/vosk-server/websocket/./asr_server.py", line 70, in recognize
await websocket.send(response)
File "/usr/lib/python3/dist-packages/websockets/protocol.py", line 555, in send
await self.ensure_open()
File "/usr/lib/python3/dist-packages/websockets/protocol.py", line 803, in ensure_open
raise self.connection_closed_exc()
websockets.exceptions.ConnectionClosedOK: code = 1000 (OK), no reason

# Konfiguration für den Vosk-Server
vosk_server_url = 'ws://xx.xx.xxx.xxx:2700'

async def run_vosk_client(uri):
    async with websockets.connect(uri) as websocket:
        print("WebSocket connection established.")

        duration = 5  # Aufnahmedauer in Sekunden
        sample_rate = 16000  # Abtastfrequenz in Hz

        print(f"Sprechen Sie etwas für {duration} Sekunden...")

        audio_data = await record_audio(duration, sample_rate)

        config_message = json.dumps({"config": {"sample_rate": sample_rate}})
        await websocket.send(config_message)

        await websocket.send(audio_data)
        await websocket.send('{"eof" : 1}')

        response = await websocket.recv()
        print(f"Erkannter Text: {response}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant