文章目录
音频合成和分析torch
代码语言:javascript
复制# -*- coding:utf-8 -*-
# /usr/bin/python
'''
@Author : Errol
@Describe:
@Evn :
@Date : -
'''
import torch
import torchaudio
import matplotlib.pyplot as plt
file_path = './data/000-test.wav'
waveform,sample_rate = torchaudio.load(file_path)
print('waveform',waveform,type(waveform),'nsample_rate:',sample_rate,type(sample_rate))
print("shape of waveform:{}".format(waveform.size))
print("sample rate of waveform:{}".format(sample_rate))
print("waveform.t(){}".format(waveform.t()))
print('type(waveform.t()))',type(waveform.t()))
print("Min of waveform: {}nMax of waveform: {}nMean of waveform: {}".format(waveform.min(), waveform.max(), waveform.mean()))
# 正则化音频数据
def normalize(waveform):
tenso