Files
pxua216mb-exp/README.md
2022-03-23 16:25:24 +08:00

50 lines
2.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# PXUA216MB-DL2-M Python例程
## 安装
本项目通过poetry实现包管理
关于poetry的安装及使用方法[poetry](https://python-poetry.org/docs/)
本项目依赖于开源项目 [sounddevice](https://python-sounddevice.readthedocs.io/en/0.4.4/installation.html)
安装poetry后简单使用```poetry install```即可安装依赖
## 使用
本例程使用[sounddevice](https://python-sounddevice.readthedocs.io/en/0.4.4/usage.html)来对音频做播放或录制,使用[soundFile](https://python-soundfile.readthedocs.io/en/0.10.3post1/)来解析音频。
测试例程请在虚拟环境下执行```src\example.py```即可
### 项目结构
```
pxua216mb-exp
├── recorded_audio
│ └── testfile.raw
├── src
│ ├── example.py
│ └── settings.py
├── test_audio
│ ├── test_audio_16k.raw
│ └── test_audio_48k.raw
├── poetry.lock
├── pyproject.toml
└── README.md
```
### 解释项目结构
- `/recorded_audio/` - 包含通过`exmaple.py`生成的音频记录文件,是音频输出的默认位置
- `/src/` - 包含项目源码,`example.py`包含了所有示例,包括主进程和几个示例函数在内,`settings.py`包括了一些设备的快速定义,这些定义将会在`example.py`中被使用。在测试时您应当执行example.py
- `/test_audio/` - 包含了所有的测试音频,`test_audio_16k.raw`是采样率16k双声道16bit位深的音频`test_audio_48k.raw`是采样率48k双声道16bit位深的音频
- `poetry.lock` - poetry的标记文件此文件不应由您手动修改
- `pyproject.toml` - 本项目通过poetry进行版本控制您可以在此处增加依赖项或更新依赖
### 寻找一个音频格式的子类型:
```python
>>> import soundfile as sf
>>> sf.available_subtypes('RAW')
>>> {'PCM_S8': 'Signed 8 bit PCM', 'PCM_16': 'Signed 16 bit PCM', 'PCM_24': 'Signed 24 bit PCM', 'PCM_32': 'Signed 32 bit PCM', 'PCM_U8': 'Unsigned 8 bit PCM', 'FLOAT': '32 bit float', 'DOUBLE': '64 bit float', 'ULAW': 'U-Law', 'ALAW': 'A-Law', 'GSM610': 'GSM
6.10', 'DWVW_12': '12 bit DWVW', 'DWVW_16': '16 bit DWVW', 'DWVW_24': '24 bit DWVW', 'VOX_ADPCM': 'VOX ADPCM'}
```