Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
TensorFlowで音声ファイルのロード
import tensorflow as tf
import matplotlib.pyplot as plt
from IPython.display import display, Audio
wav_file = 'test.wav'
wav_raw = tf.io.read_file(wav_file)
wav_tensor = tf.audio.decode_wav(wav_raw)
print('sample_rate:', wav_tensor.sample_rate)
plt.plot(wav_tensor.audio.numpy().flatten());
display(Audio(data=wav_tensor.audio.numpy().flatten(), rate=48000, normalize=False))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment