1 Star 0 Fork 0

littleNight/tacotron

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
eval.py 1.59 KB
一键复制 编辑 原始数据 按行查看 历史
yejianfeng 提交于 2019-08-17 15:06 . 把原fsf
# -*- coding: utf-8 -*-
#/usr/bin/python2
'''
By kyubyong park. kbpark.linguist@gmail.com.
https://www.github.com/kyubyong/tacotron
'''
from __future__ import print_function
from hyperparams import Hyperparams as hp
import numpy as np
from data_load import load_data
import tensorflow as tf
from train import Graph
from utils import load_spectrograms
def eval():
# Load graph 载入模型
g = Graph(mode="eval")
print("Evaluation Graph loaded")
# Load data
fpaths, text_lengths, texts = load_data(mode="eval")
# Parse
text = np.fromstring(texts[0], np.int32) # (None,)
fpaths_ = fpaths[0]
tempPath = "data/LJSpeech-1.1/wav/LJ001-0001.wav"
fname, mel, mag = load_spectrograms(tempPath)
x = np.expand_dims(text, 0) # (1, None)
y = np.expand_dims(mel, 0) # (1, None, n_mels*r)
z = np.expand_dims(mag, 0) # (1, None, n_mfccs)
saver = tf.train.Saver()
with tf.Session() as sess:
saver.restore(sess, tf.train.latest_checkpoint(hp.logdir));
print("Restored!")
writer = tf.summary.FileWriter(hp.logdir, sess.graph)
# Feed Forward
## mel
y_hat = np.zeros((1, y.shape[1], y.shape[2]), np.float32) # hp.n_mels*hp.r
for j in range(y.shape[1]):
_y_hat = sess.run(g.y_hat, {g.x: x, g.y: y_hat})
y_hat[:, j, :] = _y_hat[:, j, :]
## mag
merged, gs = sess.run([g.merged, g.global_step], {g.x:x, g.y:y, g.y_hat: y_hat, g.z: z})
writer.add_summary(merged, global_step=gs)
writer.close()
if __name__ == '__main__':
eval()
print("Done")
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/littlenight/tacotron.git
git@gitee.com:littlenight/tacotron.git
littlenight
tacotron
tacotron
master

搜索帮助