f4a6c738beabc312a848804e5c4d4f384919f026,tensorboardX/summary.py,,audio,#Any#Any#Any#,394

Before Change



def audio(tag, tensor, sample_rate=44100):
    tensor = make_np(tensor)
    tensor = tensor.squeeze()
    if abs(tensor).max() > 1:
        print("warning: audio amplitude out of range, auto clipped.")
        tensor = tensor.clip(-1, 1)
    assert(tensor.ndim == 1), "input tensor should be 1 dimensional."

    tensor_list = [int(32767.0 * x) for x in tensor]
    import io
    import wave
    import struct

After Change


    assert num_channels == 1 or num_channels == 2, "The second dimension should be 1 or 2."

    with io.BytesIO() as fio:
        soundfile.write(fio, tensor, samplerate=sample_rate, format="wav")
        audio_string = fio.getvalue()

    audio = Summary.Audio(sample_rate=sample_rate,
                          num_channels=num_channels,
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


Project Name: lanpa/tensorboardX
Commit Name: f4a6c738beabc312a848804e5c4d4f384919f026
Time: 2020-06-29
Author: prafullasd@gmail.com
File Name: tensorboardX/summary.py
Class Name:
Method Name: audio


Project Name: pytorch/examples
Commit Name: d5a75ba09ae0595ca284fd806475eb8d3f771387
Time: 2017-01-17
Author: adam.paszke@gmail.com
File Name: word_language_model/generate.py
Class Name:
Method Name: