python - ImportError:无法导入名称“枚举”
问题描述
我正在尝试使用 Google Speech API 实时识别来自麦克风输入的语音。我试过https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/speech/cloud-client/transcribe_streaming_mic.py
了,但出现了这个错误。有谁知道如何解决这个问题?
from google.cloud.speech import enums
ImportError: cannot import name 'enums'
更新: 我已经按照官方 Cloud Speech API 网站的建议通过在虚拟环境中运行代码解决了这个问题。但是,我仍然不明白为什么我们需要在虚拟环境而不是我的原始环境中运行它,因为虚拟环境不是 Linux 或其他操作系统。
解决方案
使用pip install google.cloud.speech
,您将获得最新版本,当前为V2。
在V2中,枚举和类型已被删除并且不再需要。
https://github.com/googleapis/python-speech/blob/master/UPGRADING.md#enums-and-types
推荐阅读
- php - 如何识别 Wordpress 默认文本小部件的单个实例?
- reactjs - 使用 react-router 时如何防止 React 应用程序崩溃
- laravel - 将 Laravel 从 5.4 升级到 5.7 后出现 Artisan 错误
- javascript - 如何将来自控制器的 JSON 响应存储在 Javascript 变量中
- opencv3.0 - 自适应阈值和轮廓检测
- ruby-on-rails - 我无法使用 SFTP(Filezilla 软件)通过下载文件并在本地机器文本编辑器上编辑来更新 ruby on rails 生产代码
- ios - 如何为 Mobile SDK iOS 生成许可证密钥
- sql - 看不到任何添加到我的表中的东西,如果它被添加的话
- r-exams - `exams2nops()` 中的多个图
- airflow - 气流:既没有设置 SQLALCHEMY_DATABASE_URI 也没有设置 SQLALCHEMY_BINDS