{"action":"created","issue":{"url":"https://api.github.com/repos/andabi/deep-voice-conversion/issues/24","repository_url":"https://api.github.com/repos/andabi/deep-voice-conversion","labels_url":"https://api.github.com/repos/andabi/deep-voice-conversion/issues/24/labels{/name}","comments_url":"https://api.github.com/repos/andabi/deep-voice-conversion/issues/24/comments","events_url":"https://api.github.com/repos/andabi/deep-voice-conversion/issues/24/events","html_url":"https://github.com/andabi/deep-voice-conversion/issues/24","id":301029761,"number":24,"title":"How to view the result of the conversion？","user":{"login":"shiyangccy","id":31981124,"avatar_url":"https://avatars3.githubusercontent.com/u/31981124?v=4","gravatar_id":"","url":"https://api.github.com/users/shiyangccy","html_url":"https://github.com/shiyangccy","followers_url":"https://api.github.com/users/shiyangccy/followers","following_url":"https://api.github.com/users/shiyangccy/following{/other_user}","gists_url":"https://api.github.com/users/shiyangccy/gists{/gist_id}","starred_url":"https://api.github.com/users/shiyangccy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shiyangccy/subscriptions","organizations_url":"https://api.github.com/users/shiyangccy/orgs","repos_url":"https://api.github.com/users/shiyangccy/repos","events_url":"https://api.github.com/users/shiyangccy/events{/privacy}","received_events_url":"https://api.github.com/users/shiyangccy/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-02-28T13:47:50Z","updated_at":"2018-03-01T03:30:26Z","closed_at":null,"author_association":"NONE","body":"After run the convert.py, how can I find the result? How to use tensorboard?\r\nThank you for your reply."},"comment":{"url":"https://api.github.com/repos/andabi/deep-voice-conversion/issues/comments/369463259","html_url":"https://github.com/andabi/deep-voice-conversion/issues/24#issuecomment-369463259","issue_url":"https://api.github.com/repos/andabi/deep-voice-conversion/issues/24","id":369463259,"user":{"login":"JiaYK","id":18151889,"avatar_url":"https://avatars2.githubusercontent.com/u/18151889?v=4","gravatar_id":"","url":"https://api.github.com/users/JiaYK","html_url":"https://github.com/JiaYK","followers_url":"https://api.github.com/users/JiaYK/followers","following_url":"https://api.github.com/users/JiaYK/following{/other_user}","gists_url":"https://api.github.com/users/JiaYK/gists{/gist_id}","starred_url":"https://api.github.com/users/JiaYK/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JiaYK/subscriptions","organizations_url":"https://api.github.com/users/JiaYK/orgs","repos_url":"https://api.github.com/users/JiaYK/repos","events_url":"https://api.github.com/users/JiaYK/events{/privacy}","received_events_url":"https://api.github.com/users/JiaYK/received_events","type":"User","site_admin":false},"created_at":"2018-03-01T03:30:26Z","updated_at":"2018-03-01T03:30:26Z","author_association":"NONE","body":"You can use this replace convert.py and you can get test.wav. That is the result.\r\n`# -*- coding: utf-8 -*-\r\n# /usr/bin/python2\r\n\r\n\r\nfrom __future__ import print_function\r\n\r\nimport argparse\r\n\r\nfrom data_load import get_wav_batch\r\nfrom models import Model\r\nimport numpy as np\r\nfrom utils import spectrogram2wav, inv_preemphasis\r\nfrom hparams import logdir_path\r\nimport datetime\r\nimport tensorflow as tf\r\nfrom hparams import Default as hp_default\r\nimport hparams as hp\r\n\r\nimport struct\r\nimport wave\r\n\r\ndef out_range(num):\r\n    if num > 30000:\r\n        return 30000\r\n    elif num < -30000:\r\n        return -30000\r\n    else:\r\n        return num\r\n\r\ndef out_wav(result, file_name):\r\n    n_frames = len(result)\r\n    outfile = file_name\r\n    out_wave = wave.open(outfile, 'wb')\r\n    comp_type = \"NONE\"\r\n    comp_name = \"not compressed\"\r\n    out_wave.setparams((1, 2, 16000, n_frames, comp_type, comp_name))\r\n    MAX_M = np.max(np.abs(result))\r\n\r\n    for v in result:\r\n        out_wave.writeframes(struct.pack('h', out_range(v*10000)))\r\n    out_wave.close()\r\n    print('save success')\r\n\r\ndef convert(logdir='logdir/default/train2', queue=False):\r\n\r\n    # Load graph\r\n    model = Model(mode=\"convert\", batch_size=hp.Convert.batch_size, queue=queue)\r\n\r\n    session_conf = tf.ConfigProto(\r\n        allow_soft_placement=True,\r\n        device_count={'CPU': 1, 'GPU': 0},\r\n        gpu_options=tf.GPUOptions(\r\n            allow_growth=True,\r\n            per_process_gpu_memory_fraction=0.9\r\n        ),\r\n    )\r\n    with tf.Session(config=session_conf) as sess:\r\n        # Load trained model\r\n        sess.run(tf.global_variables_initializer())\r\n        model.load(sess, 'convert', logdir=logdir)\r\n\r\n        writer = tf.summary.FileWriter(logdir, sess.graph)\r\n\r\n        coord = tf.train.Coordinator()\r\n        threads = tf.train.start_queue_runners(coord=coord)\r\n\r\n        gs = Model.get_global_step(logdir)\r\n\r\n        if queue:\r\n            pred_log_specs, y_log_spec, ppgs = sess.run([model(), model.y_spec, model.ppgs])\r\n        else:\r\n            mfcc, spec, mel = get_wav_batch(model.mode, model.batch_size)\r\n            pred_log_specs, y_log_spec, ppgs = sess.run([model(), model.y_spec, model.ppgs], feed_dict={model.x_mfcc: mfcc, model.y_spec: spec, model.y_mel: mel})\r\n\r\n        # Denormalizatoin\r\n        # pred_log_specs = hp.mean_log_spec + hp.std_log_spec * pred_log_specs\r\n        # y_log_spec = hp.mean_log_spec + hp.std_log_spec * y_log_spec\r\n        # pred_log_specs = hp.min_log_spec + (hp.max_log_spec - hp.min_log_spec) * pred_log_specs\r\n        # y_log_spec = hp.min_log_spec + (hp.max_log_spec - hp.min_log_spec) * y_log_spec\r\n\r\n        # Convert log of magnitude to magnitude\r\n        pred_specs, y_specs = np.e ** pred_log_specs, np.e ** y_log_spec\r\n\r\n        # Emphasize the magnitude\r\n        pred_specs = np.power(pred_specs, hp.Convert.emphasis_magnitude)\r\n        y_specs = np.power(y_specs, hp.Convert.emphasis_magnitude)\r\n\r\n        # Spectrogram to waveform\r\n        audio = np.array(map(lambda spec: spectrogram2wav(spec.T, hp_default.n_fft, hp_default.win_length, hp_default.hop_length, hp_default.n_iter), pred_specs))\r\n        y_audio = np.array(map(lambda spec: spectrogram2wav(spec.T, hp_default.n_fft, hp_default.win_length, hp_default.hop_length, hp_default.n_iter), y_specs))\r\n\r\n        # Apply inverse pre-emphasis\r\n        audio = inv_preemphasis(audio, coeff=hp_default.preemphasis)\r\n        y_audio = inv_preemphasis(y_audio, coeff=hp_default.preemphasis)\r\n\r\n        if not queue:\r\n            # Concatenate to a wav\r\n            y_audio = np.reshape(y_audio, (1, y_audio.size), order='C')\r\n            audio = np.reshape(audio, (1, audio.size), order='C')\r\n            out_wav(audio[0],str('test')+'.wav')\r\n            out_wav(y_audio[0],str('test')+'_y.wav')\r\n\r\n        # Write the result\r\n        tf.summary.audio('A', y_audio, hp_default.sr, max_outputs=hp.Convert.batch_size)\r\n        tf.summary.audio('B', audio, hp_default.sr, max_outputs=hp.Convert.batch_size)\r\n\r\n        # Visualize PPGs\r\n        heatmap = np.expand_dims(ppgs, 3)  # channel=1\r\n        tf.summary.image('PPG', heatmap, max_outputs=ppgs.shape[0])\r\n\r\n        writer.add_summary(sess.run(tf.summary.merge_all()), global_step=gs)\r\n        writer.close()\r\n\r\n        coord.request_stop()\r\n        coord.join(threads)\r\n\r\n\r\ndef get_arguments():\r\n    parser = argparse.ArgumentParser()\r\n    parser.add_argument('case', type=str, help='experiment case name')\r\n    arguments = parser.parse_args()\r\n    return arguments\r\n\r\n\r\nif __name__ == '__main__':\r\n    args = get_arguments()\r\n    case = args.case\r\n    logdir = '{}/{}/train2'.format(logdir_path, case)\r\n\r\n    print('case: {}, logdir: {}'.format(case, logdir))\r\n\r\n    s = datetime.datetime.now()\r\n\r\n    convert(logdir=logdir)\r\n\r\n    e = datetime.datetime.now()\r\n    diff = e - s\r\n    print(\"Done. elapsed time:{}s\".format(diff.seconds))\r\n`"}}
{"actor":{"display_login":"JiaYK"}}