README.md 2.66 KB
Newer Older
mayp777's avatar
UPDATE  
mayp777 committed
1
2
3
4
# <div align="center"><strong>TorchAudio</strong></div>

## 简介

mayp777's avatar
mayp777 committed
5
torchaudio 的目标是将 PyTorch 应用于音频领域。通过支持 PyTorch,torchaudio 遵循了相同的理念,即提供强大的 DCU 加速,注重通过 autograd 系统实现可训练的特性,并保持一致的风格(张量命名和维度命名)。因此,它主要是一个机器学习库,而不是一个通用的信号处理库。PyTorch 的优势在 torchaudio 中得以体现,所有计算都通过 PyTorch 操作完成,这使得它易于使用,并且像 PyTorch 的自然扩展。torchaudio官方github地址:[GitHub - pytorch/audio: Data manipulation and transformation for audio signal processing, powered by PyTorch](https://github.com/pytorch/audio)
mayp777's avatar
UPDATE  
mayp777 committed
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

- 支持音频输入输出(加载文件,保存文件)
  
  - 使用 SoX 将各种音频格式(如 wav、mp3、ogg、flac、opus、sphere)加载到 PyTorch 的张量中。  
  
  - 支持 Kaldi(ark/scp)格式。

- 数据加载器
  
  - 提供常见音频数据集的数据加载器。  

- 音频与语音处理功能
  
  - 强制对齐(forced_align)。  

- 常用音频变换
  
  - 提供如频谱图、AmplitudeToDB、MelScale、MelSpectrogram、MFCC、MuLaw 编码与解码、重采样等常用的音频变换。  

- 兼容性接口
  
  - 通过 PyTorch 运行与其他库(如 Kaldi)对齐的代码,包括频谱图、fbank、MFCC 等功能。

## 安装

### 适用环境

- ubuntu20.04 或 rocky8.6

- Python==3.10

37
- PyTorch==2.3.0 DTK>=24.04
mayp777's avatar
UPDATE  
mayp777 committed
38
39
40

### 使用pip方式安装

41
torchaudio whl包下载目录:[torchaudio-2.1.2+das.opt2.dtk24042-cp310-cp310-linux_x86_64.whl](http://10.6.10.68:8000/debug/torchaudio/24.04/)
mayp777's avatar
UPDATE  
mayp777 committed
42
43
44
45
46
47
48
49
50
51
52
53

```shell
pip install torchaudio* # (请下载对应操作系统的torchaudio的whl包)
```

### 源码编译安装

#### 编译环境准备

- 拉取torchaudio代码

```shell
54
git clone -b 2.1.2+das.opt2.dtk24042 http://developer.hpccube.com/codes/OpenDAS/torchaudio.git
mayp777's avatar
UPDATE  
mayp777 committed
55
56
57
58
59
60
```

- 导入环境变量以及安装必要依赖库

```shell
source /opt/dtk/env.sh
mayp777's avatar
mayp777 committed
61
cd torchaudio
mayp777's avatar
UPDATE  
mayp777 committed
62
63
64
65
66
67
68
69
70
71
72
73
bash ./test/tools/make_test_env.sh # ubuntu
bash ./test/tools/rocky8_make_test_env.sh #rocky
export PYTORCH_ROCM_ARCH="gfx928"
MAX_JOBS=16
```

#### 编译安装

- 执行编译命令并安装

```shell
CMAKE_CXX_FLAGS=-std=c++17 USE_FFMPEG=1 USE_ROCM=1 python3 setup.py bdist_wheel
mayp777's avatar
mayp777 committed
74
75
cd ..
pip install torchaudio/dist/torchaudio*
mayp777's avatar
UPDATE  
mayp777 committed
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
```

## 版本号查询

```shell
python -c "import torchaudio; print(torchaudio.__version__)"
```

- 版本号与官方版本同步,查询该软件的版本号,例如2.1.2;

## Known Issue

-

## 其他参考

- [README_ORIGIN](README_ORIGIN.md)

- [GitHub - pytorch/audio](https://github.com/pytorch/audio)