コード例 #1
0
    def load(self, checkpoint_path, model_name='tacotron'):
        print('Constructing model: %s' % model_name)
        inputs = tf.placeholder(tf.int32, [1, None], 'inputs')
        input_lengths = tf.placeholder(tf.int32, [1], 'input_lengths')
        identity = tf.placeholder(tf.int32, [1], 'identity')
        with tf.variable_scope('model') as scope:
            hparams.chinese_symbol = True
            hparams.max_iters = 400
            self.model = create_model(model_name, hparams)
            reader2 = pywrap_tensorflow.NewCheckpointReader(checkpoint_path)
            var_to_shape_map = reader2.get_variable_to_shape_map()
            id_num = var_to_shape_map['model/inference/embedding_id'][0]
            self.model.initialize(inputs,
                                  input_lengths,
                                  identities=identity,
                                  id_num=id_num)
            self.wav_output = audio.inv_spectrogram_tensorflow(
                self.model.linear_outputs[0])
            self.alignment = self.model.alignments[0]

        print('Loading checkpoint: %s' % checkpoint_path)
        self.session = tf.Session()
        self.session.run(tf.global_variables_initializer())
        saver = tf.train.Saver()
        saver.restore(self.session, checkpoint_path)
コード例 #2
0
    def load(self, checkpoint_path, reference_mel=None, model_name='tacotron'):
        print('Constructing model: %s' % model_name)
        inputs = tf.placeholder(tf.int32, [1, None], 'inputs')
        input_lengths = tf.placeholder(tf.int32, [1], 'input_lengths')
        if reference_mel is not None:
            reference_mel = tf.placeholder(tf.float32,
                                           [1, None, hparams.num_mels],
                                           'reference_mel')
        # Only used in teacher-forcing generating mode
        if self.teacher_forcing_generating:
            mel_targets = tf.placeholder(tf.float32,
                                         [1, None, hparams.num_mels],
                                         'mel_targets')
        else:
            mel_targets = None

        with tf.variable_scope('model') as scope:
            self.model = create_model(model_name, hparams)
            self.model.initialize(inputs,
                                  input_lengths,
                                  mel_targets=mel_targets,
                                  reference_mel=reference_mel)
            self.wav_output = audio.inv_spectrogram_tensorflow(
                self.model.linear_outputs[0])
            self.alignments = self.model.alignments[0]

        print('Loading checkpoint: %s' % checkpoint_path)
        self.session = tf.Session()
        self.session.run(tf.global_variables_initializer())
        saver = tf.train.Saver()
        saver.restore(self.session, checkpoint_path)
コード例 #3
0
ファイル: synthesizer.py プロジェクト: Jim-Song/n_tacotron
    def load(self, checkpoint_path, model_name='tacotron'):
        print('Constructing model: %s' % model_name)
        inputs = tf.placeholder(tf.int32, [1, None], 'inputs')
        input_lengths = tf.placeholder(tf.int32, [1], 'input_lengths')
        mel_spec = tf.placeholder(tf.float32,
                                  [None, None, self.hparams.num_mels],
                                  'mel_targets')

        with tf.variable_scope('model') as scope:

            if self.hparams.enable_fv1 or self.hparams.enable_fv2:
                self.net = ResCNN(data=mel_spec, hyparam=self.hparams)
                self.net.inference()

                voice_print_feature = tf.reduce_mean(self.net.features, 0)
            else:
                voice_print_feature = None

            self.model = create_model(model_name, self.hparams)
            self.model.initialize(inputs=inputs,
                                  input_lengths=input_lengths,
                                  voice_print_feature=voice_print_feature)
            self.wav_output = audio.inv_spectrogram_tensorflow(
                self.model.linear_outputs[0])

        print('Loading checkpoint: %s' % checkpoint_path)
        self.session = tf.Session()
        self.session.run(tf.global_variables_initializer())
        saver = tf.train.Saver()
        saver.restore(self.session, checkpoint_path)
コード例 #4
0
ファイル: synthesizer.py プロジェクト: DorsetProject/tacotron
    def update(self):
        with tf.variable_scope('model') as scope:
            self.model.update(hparams)
            self.wav_output = audio.inv_spectrogram_tensorflow(
                self.model.linear_outputs[0])

        print('Loading checkpoint: %s' % self.checkpoint_path)
        self.session = tf.Session()
        self.session.run(tf.global_variables_initializer())
        saver = tf.train.Saver()
        saver.restore(self.session, self.checkpoint_path)
コード例 #5
0
ファイル: eval.py プロジェクト: Bruce-Stark/SV-Tacotron
  def load(self, checkpoint_path, model_name='tacotron'):
    inputs = tf.placeholder(tf.int32, [1, None], 'inputs')
    input_lengths = tf.placeholder(tf.int32, [1], 'input_lengths')
    with tf.variable_scope('model') as scope:
      self.model = Tacotron(hparams)
      self.model.initialize(inputs, input_lengths)
      self.wav_output = audio.inv_spectrogram_tensorflow(self.model.linear_outputs[0])

    # 读取已有模型
    self.session = tf.Session()
    self.session.run(tf.global_variables_initializer())
    saver = tf.train.Saver()
    saver.restore(self.session, checkpoint_path)
コード例 #6
0
  def load(self, checkpoint_path, model_name='tacotron'):
    print('Constructing model: %s' % model_name)
    inputs = tf.placeholder(tf.int32, [1, None], 'inputs')
    input_lengths = tf.placeholder(tf.int32, [1], 'input_lengths')
    with tf.variable_scope('model') as scope:
      self.model = create_model(model_name, hparams)
      self.model.initialize(inputs, input_lengths)
      self.wav_output = audio.inv_spectrogram_tensorflow(self.model.linear_outputs[0])

    print('Loading checkpoint: %s' % checkpoint_path)
    self.session = tf.Session()
    self.session.run(tf.global_variables_initializer())
    saver = tf.train.Saver()
    saver.restore(self.session, checkpoint_path)
コード例 #7
0
ファイル: synthesizer.py プロジェクト: keithito/tacotron
  def load(self, checkpoint_path, model_name='tacotron'):
    print('Constructing model: %s' % model_name)
    inputs = tf.placeholder(tf.int32, [1, None], 'inputs')
    input_lengths = tf.placeholder(tf.int32, [1], 'input_lengths')
    with tf.variable_scope('model') as scope:
      self.model = create_model(model_name, hparams)
      self.model.initialize(inputs, input_lengths)
      self.wav_output = audio.inv_spectrogram_tensorflow(self.model.linear_outputs[0])

    print('Loading checkpoint: %s' % checkpoint_path)
    self.session = tf.Session()
    self.session.run(tf.global_variables_initializer())
    saver = tf.train.Saver()
    saver.restore(self.session, checkpoint_path)
コード例 #8
0
ファイル: synthesizer.py プロジェクト: param17/Songbird
    def load(self, checkpoint_path, vgg19_path, model_name='tacotron'):
        print('Constructing model: %s' % model_name)
        inputs = tf.placeholder(tf.float32,
                                [1, hparams.image_dim, hparams.image_dim, 3],
                                'inputs')
        with tf.variable_scope('model') as _:
            self.model = create_model(model_name, hparams)
            self.model.initialize(inputs, vgg19_path)
            self.wav_output = audio.inv_spectrogram_tensorflow(
                self.model.linear_outputs[0])

        print('Loading checkpoint: %s' % checkpoint_path)
        self.session = tf.Session()
        self.session.run(tf.global_variables_initializer())
        checkpoint_saver = tf.train.import_meta_graph(
            '%s.%s' % (checkpoint_path, 'meta'))
        checkpoint_saver.restore(self.session, checkpoint_path)
コード例 #9
0
    def load(self, checkpoint_path, model_name='tacotron'):
        print('Constructing model: %s' % model_name)
        inputs = tf.placeholder(tf.int32, [1, None], 'inputs')
        input_lengths = tf.placeholder(tf.int32, [1], 'input_lengths')
        with tf.variable_scope('model') as scope:
            self.model = create_model(model_name, hparams)
            self.model.initialize(inputs, input_lengths)
            self.wav_output = audio.inv_spectrogram_tensorflow(
                self.model.linear_outputs[0])

        print('Loading checkpoint: %s' % checkpoint_path)
        config = tf.ConfigProto()
        # making core utilization optimal, low value more optimaztion
        config.gpu_options.per_process_gpu_memory_fraction = 0.2

        self.session = tf.Session(config=config)
        self.session.run(tf.global_variables_initializer())
        saver = tf.train.Saver()
        saver.restore(self.session, checkpoint_path)
コード例 #10
0
import tensorflow as tf
from models import create_model
from util import audio
from hparams import hparams

checkpoint_path = "/tacotron-20180906/model.ckpt"
model_name = 'tacotron'
inputs = tf.placeholder(tf.int32, [1, None], 'inputs')
input_lengths = tf.placeholder(tf.int32, [1], 'input_lengths')
with tf.variable_scope('model') as scope:
    model = create_model(model_name, hparams)
    model.initialize(inputs, input_lengths)
    wav_output = audio.inv_spectrogram_tensorflow(model.linear_outputs[0])

print('Loading checkpoint: %s' % checkpoint_path)

session = tf.Session()
session.run(tf.global_variables_initializer())
saver = tf.train.Saver()
saver.restore(session, checkpoint_path)

with open("eval.pb", 'w') as f:
    g = tf.get_default_graph()
    f.write(str(g.as_graph_def()))