speechmatics-python
speechmatics-python copied to clipboard
`AttributeError: module 'websockets' has no attribute 'connect'` when running RT transcription example
Describe the bug
When running the real-time transcription example from the Speechmatics documentation using Python 3.11, an AttributeError is raised: AttributeError: module 'websockets' has no attribute 'connect'
To Reproduce Steps to reproduce the behavior:
- Install Python 3.11 and create a virtual environment
- Install the latest version of
speechmatics-pythonfrom PyPI - Run the real-time transcription example from the documentation with a valid API key and The Radio Stream (Link)
- Observe the error during execution
Expected behavior The transcription should start and print partial/full transcripts in the terminal without raising an exception.
Additional context Error traceback:
File ".../speechmatics/client.py", line 526, in run_synchronously
asyncio.run(asyncio.wait_for(self.run(*args, **kwargs), timeout=timeout))
...
File ".../speechmatics/client.py", line 497, in run
async with websockets.connect( # pylint: disable=no-member
^^^^^^^^^^^^^
AttributeError: module 'websockets' has no attribute 'connect
Hi @ouardiYakoubAbdallah
Can you run these commands and post the output here?
- pip3 freeze
- python3 --version
The output should look similar to this:
/tmp pip3 freeze
anyio==4.9.0
certifi==2025.1.31
click==8.1.8
docopt==0.6.2
h11==0.14.0
h2==4.2.0
hpack==4.1.0
httpcore==1.0.7
httpx==0.28.1
hyperframe==6.1.0
idna==3.10
jiwer==3.1.0
markdown-it-py==3.0.0
mdurl==0.1.2
more-itertools==10.6.0
numpy==2.2.4
pandas==2.2.3
polling2==0.5.0
pyannote.core==5.0.0
pyannote.database==5.1.3
Pygments==2.19.1
python-dateutil==2.9.0.post0
pytz==2025.2
PyYAML==6.0.2
RapidFuzz==3.13.0
regex==2024.11.6
rich==14.0.0
scipy==1.15.2
shellingham==1.5.4
six==1.17.0
sniffio==1.3.1
sortedcontainers==2.4.0
speechmatics-python==3.0.3
tabulate==0.9.0
tenacity==8.2.3
toml==0.10.2
typer==0.15.2
typing_extensions==4.13.1
tzdata==2025.2
websockets==13.0.1
/tmp python3 --version
Python 3.11.11
- pip freeze output:
...
PyYAML==6.0.1
radon==6.0.1
RapidFuzz==3.12.2
redis==5.0.3
referencing==0.36.2
regex==2024.11.6
requests==2.32.3
requests-oauthlib==2.0.0
requests-toolbelt==1.0.0
rich==13.9.4
rpds-py==0.22.3
rsa==4.9
Rtree==1.3.0
ruff==0.8.2
safetensors==0.5.2
schedule==1.2.2
scikit-image==0.25.2
scikit-learn==1.6.1
scim2-filter-parser==0.5.0
scipy==1.15.2
semchunk==2.2.2
sendgrid==6.11.0
sentence-transformers==3.4.1
shapely==2.0.7
shellingham==1.5.4
simple-websocket==1.1.0
simsimd==6.2.1
six==1.17.0
sly==0.5
smart-open==7.1.0
sniffio==1.3.1
sortedcontainers==2.4.0
soupsieve==2.6
spacy==3.8.4
spacy-langdetect==0.1.2
spacy-legacy==3.0.12
spacy-loggers==1.0.5
speechmatics-python==3.0.3
SQLAlchemy==2.0.29
SQLAlchemy-Utils==0.41.2
srsly==2.5.1
stack-data==0.6.3
starkbank-ecdsa==2.2.0
stevedore==5.4.0
sympy==1.13.1
tabulate==0.9.0
tenacity==8.2.3
thinc==8.3.4
threadpoolctl==3.5.0
tifffile==2025.2.18
tiktoken==0.9.0
tokenizers==0.21.0
toml==0.10.2
tomlkit==0.13.2
torch==2.6.0
torchvision==0.21.0
tornado==6.4.2
tqdm==4.67.1
traitlets==5.14.3
transformers==4.49.0
triton==3.2.0
typer==0.12.5
types-paramiko==3.3.0.0
types-python-dateutil==2.9.0.20240316
types-pytz==2024.1.0.20240203
types-requests==2.32.0.20241016
typing_extensions==4.12.2
tzdata==2025.1
tzlocal==5.3
urllib3==2.3.0
vcrpy==7.0.0
vine==5.1.0
virtualenv==20.26.6
vulture==2.11
wasabi==1.1.3
wcwidth==0.2.13
weasel==0.4.1
websocket-client==1.7.0
websockets==13.0.1
...
- Python version: Python 3.11.11
Can you try installing latest websockets pip3 install websockets==15.0.1?
If that doesn't work, try uninstalling and re-installing speechmatics client.
Same, it doesn't work ...
Hi @ouardiYakoubAbdallah,
Can you try to create a new venv to run the example? Looking at your list of dependencies you have a lot of extra dependencies that are not required to run it.
When installed correctly you should see this:
Starting transcription (type Ctrl-C to stop):
[partial]
[partial] All over
[partial] All over the course of
[partial] All over the course of the
[partial] All over the course of the Parliament
[ FULL] All
...
Hello @dumitrugutu
Already tested it with a clean venv and with force reinstall and still the same issue, i'm using it with raw socketio to bypass this "blockage" ...