Uberi / speech_recognition

Speech recognition module for Python, supporting several engines and APIs, online and offline.
https://pypi.python.org/pypi/SpeechRecognition/
BSD 3-Clause "New" or "Revised" License
8.45k stars 2.4k forks source link

Fix WinError 10054 #751

Closed Hexer-7 closed 6 months ago

Hexer-7 commented 6 months ago

added SSL to "endpoint" url, help users who had issue "WinError 10054"

ftnext commented 6 months ago

@Hexer-7 Thanks! Could you tell me the link of "WinError 10054" issue?

Hexer-7 commented 6 months ago

https://github.com/Uberi/speech_recognition/issues/733

ftnext commented 6 months ago

@Hexer-7 Thanks. Could you please demonstrate how this pull request addresses the issue?

Hexer-7 commented 6 months ago

This issue has personally confronted me, and I've tried to investigate its causes. I noticed that sometimes when running the code in PyCharm, the server responds once, then stops responding, leading to the "WinError 10054" problem. I suspect that the firewall is rejecting access in a certain way. However, what's certain is that when I attempted to extract the speech-to-text API from Chrome, I noticed it was sending requests to "https://www.google.com/speech-api/full-duplex/v1/up". This caught my attention, comparing it to the link in the library, which lacks SSL. I modified the library's link, adding SSL to it, and observed that the problem was completely resolved. Therefore, I believe that the cause of the problem is SSL-related, possibly due to the type of connection used or the firewall. I'm not entirely sure, but this solution emerged from my experimentation, and I hope it proves useful.

ftnext commented 6 months ago

@Hexer-7 Thank you very much for your detailed reply. It convinced me that adding SSL to "endpoint" url is helpful.

When specifying a specific URL, various approaches can be considered. In addition to hardcoding, there may be implementations that allow users to pass URLs as well. My idea: https://github.com/Uberi/speech_recognition/pull/754 I think it is better for users to pass URL than hardcoding.

I close this PR, but I appreciate your investigation and proposal. Many thanks