Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google cloud storage 从google.cloud导入语音导入错误:DLL加载失败:Ненайденауказаннаяпроцедура;_Google Cloud Storage_Google Speech Api - Fatal编程技术网

Google cloud storage 从google.cloud导入语音导入错误:DLL加载失败:Ненайденауказаннаяпроцедура;

Google cloud storage 从google.cloud导入语音导入错误:DLL加载失败:Ненайденауказаннаяпроцедура;,google-cloud-storage,google-speech-api,Google Cloud Storage,Google Speech Api,我想创建一个电报机器人,将音频转换为文本格式,并将其存储在谷歌云存储中,为此我导入了谷歌coud库 如果您可以看到,其他库导入成功且没有错误,除非google cloud speech/-storage 当我运行脚本时,它会返回如下错误消息: Traceback (most recent call last): File "C:/Users/USER/Documents/python projects/s2t/bot.py", line 9, in <module> f

我想创建一个电报机器人,将音频转换为文本格式,并将其存储在谷歌云存储中,为此我导入了谷歌coud库 如果您可以看到,其他库导入成功且没有错误,除非google cloud speech/-storage 当我运行脚本时,它会返回如下错误消息:

Traceback (most recent call last):
  File "C:/Users/USER/Documents/python projects/s2t/bot.py", line 9, in 
<module>
    from google.cloud import speech_v1
  File "C:\Users\USER\Documents\python projects\s2t\lib\site- 
packages\google\cloud\speech_v1\__init__.py", line 17, in <module>
    from google.cloud.speech_v1.gapic import speech_client
  File "C:\Users\USER\Documents\python projects\s2t\lib\site- 
packages\google\cloud\speech_v1\gapic\speech_client.py", line 24, in 
<module>
    import google.api_core.gapic_v1.client_info
  File "C:\Users\USER\Documents\python projects\s2t\lib\site- 
packages\google\api_core\gapic_v1\__init__.py", line 16, in <module>
    from google.api_core.gapic_v1 import config
  File "C:\Users\USER\Documents\python projects\s2t\lib\site- 
packages\google\api_core\gapic_v1\config.py", line 27, in <module>
    from google.api_core import retry
  File "C:\Users\USER\Documents\python projects\s2t\lib\site- 
packages\google\api_core\retry.py", line 67, in <module>
    from google.api_core import datetime_helpers
  File "C:\Users\USER\Documents\python projects\s2t\lib\site- 
packages\google\api_core\datetime_helpers.py", line 23, in <module>
    from google.protobuf import timestamp_pb2
  File "C:\Users\USER\Documents\python projects\s2t\lib\site- 
packages\google\protobuf\timestamp_pb2.py", line 7, in <module>
    from google.protobuf import descriptor as _descriptor
  File "C:\Users\USER\Documents\python projects\s2t\lib\site- 
packages\google\protobuf\descriptor.py", line 47, in <module>
    from google.protobuf.pyext import _message
ImportError: DLL load failed: Не найдена указанная процедура.


Here is my code:

from __future__ import unicode_literals
from telegram.ext import Updater
from telegram.ext import CommandHandler
from telegram.ext import MessageHandler
from telegram.ext import Filters
from telegram.ext.dispatcher import run_async
from telegram import ChatAction
from tinytag import TinyTag
from google.cloud import speech
from google.cloud import storage

from google.cloud.speech import enums
from google.cloud.speech import types
import os
import io

TOKEN = '1048019183:AAFebrbxYt1kz_73M7uSvhL5SC1AOG6NCnk'
PORT = int(os.environ.get('PORT', '5002'))
BUCKET_NAME = 'botkvartal'
ADMIN_CHAT_ID = 123456
updater = Updater(TOKEN)
dispatcher = updater.dispatcher

def start(bot, update):
    bot.send_message(chat_id=update.message.chat_id, text="Пожалуйста, 
воспользуйтесь аудио обращением к нашему боту")


def voice_to_text(bot, update):
    chat_id = update.message.chat.id
    file_name = str(chat_id) + '_' + str(update.message.from_user.id) + 
str(update.message.message_id) + '.ogg'

    update.message.voice.get_file().download(file_name)
    tag = TinyTag.get(file_name)
    length = tag.duration

    speech_client = speech.SpeechClient()

    to_gs = length > 58

    if to_gs:
        storage_client = storage.Client()

        bucket = storage_client.get_bucket(BUCKET_NAME)
        blob = bucket.blob(file_name)
        blob.upload_from_filename(file_name)
        audio = types.RecognitionAudio(uri='gs://' + BUCKET_NAME + '/' + 
file_name)
    else:
        with io.open(file_name, 'rb') as audio_file:
            content = audio_file.read()
            audio = types.RecognitionAudio(content=content)

    config = types.RecognitionConfig(
        encoding=enums.RecognitionConfig.AudioEncoding.OGG_OPUS,
        sample_rate_hertz=tag.samplerate,
        language_code='ru-RU')

    bot.send_chat_action(chat_id=chat_id, action=ChatAction.TYPING)
    response = speech_client.long_running_recognize(config, 
audio).result(timeout=500) \
        if to_gs else \
        speech_client.recognize(config, audio)

    message_text = ''
    for result in response.results:
        message_text += result.alternatives[0].transcript + '\n'

    update.message.reply_text(message_text)
    os.remove(file_name)


def ping_me(bot, update, error):
    if not error.message == 'Timed out':
        bot.send_message(chat_id=ADMIN_CHAT_ID, text=error.message)


start_handler = CommandHandler(str('start'), start)
oh_handler = MessageHandler(Filters.voice, voice_to_text)
dispatcher.add_handler(start_handler)
dispatcher.add_handler(oh_handler)
dispatcher.add_error_handler(ping_me)
updater.start_polling()
updater.idle()
回溯(最近一次呼叫最后一次):
文件“C:/Users/USER/Documents/python projects/s2t/bot.py”,第9行,在
从google.cloud导入语音_v1
文件“C:\Users\USER\Documents\python projects\s2t\lib\site-
packages\google\cloud\speech\u v1\\uuuuu init\uuuuuu.py”,第17行,在
从google.cloud.speech\u v1.gapic导入speech\u客户端
文件“C:\Users\USER\Documents\python projects\s2t\lib\site-
packages\google\cloud\speech\u v1\gapic\speech\u client.py”,第24行,在
导入google.api_core.gapic_v1.client_信息
文件“C:\Users\USER\Documents\python projects\s2t\lib\site-
packages\google\api\u core\gapic\u v1\\uuuuu init\uuuuuuuuuu.py”,第16行,在
从google.api_core.gapic_v1导入配置
文件“C:\Users\USER\Documents\python projects\s2t\lib\site-
packages\google\api\u core\gapic\u v1\config.py”,第27行,在
从google.api_核心导入重试
文件“C:\Users\USER\Documents\python projects\s2t\lib\site-
packages\google\api\u core\retry.py”,第67行,在
从google.api\u核心导入日期时间\u帮助程序
文件“C:\Users\USER\Documents\python projects\s2t\lib\site-
packages\google\api\u core\datetime\u helpers.py”,第23行,在
从google.protobuf导入时间戳_pb2
文件“C:\Users\USER\Documents\python projects\s2t\lib\site-
packages\google\protobuf\timestamp_pb2.py”,第7行,in
从google.protobuf导入描述符作为_描述符
文件“C:\Users\USER\Documents\python projects\s2t\lib\site-
packages\google\protobuf\descriptor.py”,第47行
从google.protobuf.pyext导入消息
导入错误:DLL加载失败:crmk_аааазаааааа。
这是我的密码:
从未来导入unicode文字
从telegram.ext导入更新程序
从telegram.ext导入命令处理程序
从telegram.ext导入MessageHandler
从telegram.ext导入过滤器
从telegram.ext.dispatcher导入运行异步
从电报输入操作
从tinytag进口tinytag
从google.cloud导入语音
从google.cloud导入存储
从google.cloud.speech导入枚举
从google.cloud.speech导入类型
导入操作系统
输入io
令牌='104801983:AAFebrbxYt1kz_73M7uSvhL5SC1AOG6NCnk'
PORT=int(os.environ.get('PORT','5002'))
BUCKET_NAME='botkpartal'
管理员聊天ID=123456
更新程序=更新程序(令牌)
dispatcher=updater.dispatcher
def启动(机器人,更新):
bot.send_message(chat_id=update.message.chat_id,text=“Пжжжаааааааа1072,
воспользуйтесь аудио обращением к нашему боту")
def语音到文字(机器人,更新):
chat\u id=update.message.chat.id
file_name=str(chat_id)+''+str(update.message.from_user.id)+
str(update.message.message_id)+'.ogg'
update.message.voice.get_file()下载(文件名)
tag=TinyTag.get(文件名)
长度=tag.duration
speech\u client=speech.SpeechClient()
to_gs=长度>58
如有需要:
storage\u client=storage.client()
bucket=存储\客户端。获取\ bucket(bucket\名称)
blob=bucket.blob(文件名)
blob.upload\u from\u filename(文件名)
audio=types.RecognitionAudio(uri='gs://'+BUCKET_NAME+'/'+
文件名(U)
其他:
以io.open(文件名,'rb')作为音频文件:
content=audio_file.read()
音频=类型。识别音频(内容=内容)
config=types.RecognitionConfig(
encoding=enums.RecognitionConfig.AudioEncoding.OGG_OPUS,
采样率\u赫兹=tag.samplerate,
语言(代码为ru-ru)
bot.send\u chat\u action(chat\u id=chat\u id,action=ChatAction.TYPING)
response=speech\u client.long\u running\u recognize(配置,
音频)。结果(超时=500)\
如果是其他的话\
语音识别(配置、音频)
消息文本=“”
对于response.results中的结果:
消息\u text+=result.alternations[0]。转录本+'\n'
update.message.reply_文本(message_文本)
删除(文件名)
def ping_me(机器人、更新、错误):
如果不是,则返回错误消息==“超时”:
bot.send\u message(chat\u id=ADMIN\u chat\u id,text=error.message)
start\u handler=CommandHandler(str('start'),start)
oh_handler=MessageHandler(Filters.voice,voice_to_text)
dispatcher.add\u处理程序(启动\u处理程序)
dispatcher.add\u处理程序(oh\u处理程序)
dispatcher.add\u error\u处理程序(ping\u me)
updater.start_polling()
updater.idle()

这段代码是开源的,我在github中找到了它,但是在排除了google云库的导入错误后,我想在其中添加一些功能

您应该尝试将protobuf降级到3.6.0

install protobuf==3.6.0
或检查:

在protobuf-3.6.1-py2.py3-none-any.whl和Python 2.7.10(64位)处于启用状态时 Windows 7 Lib\site packages\google\protobuf\pyext\u message.pyd 文件不存在

使用protobuf-3.6.1-cp36-cp36m-win_amd64.whl和Python 3.6.1(64位) 在Windows 7上,此文件确实存在:

Lib\site packages\google\protobuf\pyext\u message.cp36-win\u amd64.pyd

当我从上面的google.protobuf.pyext import\u消息运行时 Python3环境—它成功无误


你能试试pip安装protobuf==3.6.0吗@marian,vladoi,谢谢你!这对你有用吗?@marian.vladoi,绝对有效。我也非常震惊xDok,我会把它作为一个答案,并请大家投票,为社区提高知名度。