amazon-web-services - 模块初始化错误:
问题描述
在 lambda 函数中执行测试配置时我面临此错误模块初始化错误:<urlopen 错误 [Errno 110] 连接超时>
我在使用torch.hub.load
. 请帮我弄清楚这个问题。谢谢。
import torch
import numpy as np
import urllib
print(np.__version__);print(np.__file__)
#from scipy.io.wavfile import write
from os import path
print(torch.__version__)
print(torch.cuda.is_available())
waveglow_path = torch.hub.load('nvidia/DeepLearningExamples:torchhub',
'nvidia_waveglow')
waveglow = waveglow_path.to('cuda')
waveglow.eval()
#waveglow.cpu().eval()
import boto3
bucket = 'ttsmodel'
key= 'TTS_Nigerian'
dest_file = '/tmp/'
model_path = dest_file
#def load_model():
#model_path = get_model()
#tacotron2 = torch.hub.load('nvidia/DeepLearningExamples:torchhub',
'nvidia_tacotron2')
#tacotron2.load_state_dict(torch.load(model_path)['state_dict'])
#tacotron2 = tacotron2.to('cuda')
#tacotron2.eval()
#return tacotron2
tmp_file_path = "\tmp\TTS_Nigerian"
def lambda_handler(event, context):
s3 = boto3.resource('s3')
s3.Bucket(bucket).download_file(key, dest_file)
#os.path.isfile('/tmp/' + filename)
model_path= dest_file
tacotron2 = torch.hub.load('nvidia/DeepLearningExamples:torchhub',
'nvidia_tacotron2')
tacotron2.load_state_dict(torch.load(model_path)['state_dict'])
tacotron2 = tacotron2.to('cuda')
tacotron2.eval()
#s3 = boto3.resource('s3')
#with open('TTS_Nigerian', wb) as tacotron2:
#s3.Bucket(bucket).download_file(key, tacotron2)
#tacotron2 = load_model()
text = "Dear User, Your guider got closed unexpectedly.Would you
like to continue from where you left off."
utils = torch.hub.load('NVIDIA/DeepLearningExamples:torchhub',
'nvidia_tts_utils')
sequence, lengths = utils.prepare_input_sequence([text])
with torch.no_grad():
mel_output_postnet, _, alignment = tacotron2.infer(sequence, lengths)
audio = waveglow.infer(mel_output_postnet)
#plot_data((mel_output_postnet.float().data.cpu().numpy()[0],
#alignment.float().data.cpu().numpy()[0].T))
audio_numpy = audio[0].data.cpu().numpy()
sampling_rate = 22050
from IPython.display import Audio
Audio(audio_numpy, rate=sampling_rate)
解决方案
推荐阅读
- python-3.x - Windows 中的 Tthis 代码
- python - How to flatten a Pandas dataframe json field that sometimes contains a list and sometimes a value
- visual-studio - 项目 * 需要部署才能启动
- excel - 将数据从一个工作表复制到另一个工作簿,但出现一些超出范围的错误
- nasm - 获取 VBE 信息
- python-3.x - 操作 sympy 表达式树
- sql - 遇到异常oracle PLSQL时程序的执行流程
- python - 如何将 numpy uint8 转换为 Python 中的默认 int 类型?
- vba - 使用变量过滤列表框的问题
- javascript - 如何在下一次迭代之前在 JavaScript 循环中添加延迟?