diff --git a/.gitignore b/.gitignore index f1d6420..a138958 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ dist* __pycache__* run.spec alispeech.log -*.wav \ No newline at end of file +*.wav +token.ini \ No newline at end of file diff --git a/.idea/CapsWriter.iml b/.idea/CapsWriter.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/.idea/CapsWriter.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..25c7467 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,88 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..7848122 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 71cf397..b4ca447 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ setuptools pyaudio keyboard -aliyunsdkcore +aliyun-python-sdk-core==2.13.3 configparser \ No newline at end of file diff --git a/run.py b/run.py index 8cb3a00..44d14dc 100644 --- a/run.py +++ b/run.py @@ -138,15 +138,16 @@ def process(): def recoder(recognizer, p): global run try: + ret = recognizer.start() + if ret < 0: + return ret stream = p.open(channels=CHANNELS, format=FORMAT, rate=RATE, input=True, frames_per_buffer=CHUNK) print('\r{}//:在听了,说完了请松开 CapsLock 键...'.format(count), end=' ') - ret = recognizer.start() - if ret < 0: - return ret + while run: data = stream.read(CHUNK) ret = recognizer.send(data) diff --git a/token.ini b/token.ini deleted file mode 100644 index bbaa9d5..0000000 --- a/token.ini +++ /dev/null @@ -1,7 +0,0 @@ -[Token] -id = 00000000000000000000 -expiretime = 0000000000 -accesskeyid = 00000000000000 -accesskeysecret = 000000000000000000000000000 -appkey = 000000000000000000000 - diff --git a/安装指南/requirements.txt b/安装指南/requirements.txt index 71cf397..b4ca447 100644 --- a/安装指南/requirements.txt +++ b/安装指南/requirements.txt @@ -1,5 +1,5 @@ setuptools pyaudio keyboard -aliyunsdkcore +aliyun-python-sdk-core==2.13.3 configparser \ No newline at end of file diff --git a/安装指南/安装指南.md b/安装指南/安装指南.md index 3ca4b61..bac7230 100644 --- a/安装指南/安装指南.md +++ b/安装指南/安装指南.md @@ -6,12 +6,19 @@ ``` pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple +pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ pip install setuptools keyboard aliyunsdkcore configparser cd alibabacloud-nls-python-sdk python setup.py bdist_egg python setup.py install ``` + + +在你 `pip install aliyunsdkcore` 这一步几乎百分百可能会因为安装依赖包 `pycrypto` 而失败。解决办法是,先安装 `Microsoft Visual Studio 14.0`,再在命令行里运行 `set CL=-FI"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdint.h"`,再执行 `pip install aliyunsdkcore ` + + + 此外,还有一个依赖 `pyaudio` 不是太好安装,需要先到 [这个链接](https://www.lfd.uci.edu/~gohlke/pythonlibs) 下载 pyaudio 对应版本的 whl 文件。例如,我安装的是 python3.7 64位版本,就下载 `PyAudio‑0.2.11‑cp37‑cp37m‑win_amd64.whl` ,放到本文件夹,用 ``` @@ -20,6 +27,10 @@ pip install PyAudio‑0.2.11‑cp37‑cp37m‑win_amd64.whl 安装好 pyaudio。(为了方便,作者已经将 python3.6 到 3.9 的 whl 文件下载到本文件夹,根据版本选择安装即可) + + +安装阿里云的 `aliyunsdkcore` 不要用 `pip install aliyunsdkcore`, 那样下载来的是不能用的旧版本。应该使用 `pip install aliyun-python-sdk-core==2.13.3` + ## API 配置 ### 开通服务