Skip to content

Commit

Permalink
Add websocket-client version
Browse files Browse the repository at this point in the history
  • Loading branch information
nshmyrev committed Apr 25, 2023
1 parent 9f6d71e commit b60de10
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions client-samples/python/asr-test-client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env python3

import wave
import sys

from websocket import create_connection

ws = create_connection("ws://localhost:2700")

wf = wave.open(sys.argv[1], "rb")
ws.send('{ "config" : { "sample_rate" : %d } }' % (wf.getframerate()))
buffer_size = int(wf.getframerate() * 0.2) # 0.2 seconds of audio
while True:
data = wf.readframes(buffer_size)

if len(data) == 0:
break

ws.send_binary(data)
print (ws.recv())

ws.send('{"eof" : 1}')
print (ws.recv())

0 comments on commit b60de10

Please sign in to comment.