File size: 1,936 Bytes
fa44d96
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# Audex Enhancement VAE

This directory contains the Audex enhancement VAE used to convert
XCodec1-decoded 16 kHz mono WAV audio into enhanced 48 kHz mono WAV audio.

The enhancement model is a postprocessor for Audex text-to-audio generation:

```text
Audex generation -> XCodec1 decode -> 16 kHz WAV -> Enhancement VAE -> 48 kHz WAV
```

The model is intended for XCodec1-decoded Audex audio as inputs. It is not a general
purpose enhancer for arbitrary audio.


## Requirements
- `torch, numpy, scipy`

## Command Line Usage

For a folder of outputs:

```bash
python enhancement_VAE/enhance_audio_48k.py \
  --input tta_outputs \
  --output-dir tta_outputs_enhanced_48k
```

For a single WAV file:

```bash
python enhancement_VAE/enhance_audio_48k.py \
  --input tta_outputs/example.wav \
  --output-dir tta_outputs_enhanced_48k
```

Outputs are written as:

```text
<input_stem>_enhanced_48k.wav
```

Supported options:

- `--device`: inference device. Defaults to `cuda` when available, otherwise `cpu`.
- `--seed`: torch seed for stochastic VAE sampling. Defaults to `0`.
- `--deterministic`: use the posterior mean instead of VAE sampling.

## Python API

```python
from pathlib import Path
import torch

from enhancement_VAE.enhancement_vae import enhance_file, load_model

root = Path("enhancement_VAE")
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

model = load_model(
    checkpoint_path=root / "XCodec_RVQ4_mono_causal_fp32.safetensors",
    config_path=root / "config.json",
    device=device,
)

enhance_file(
    model=model,
    input_path=Path("input_16k.wav"),
    output_path=Path("input_16k_enhanced_48k.wav"),
    deterministic=False,
)
```

## Input and Output

Input:

- XCodec1-decoded Mono 16 kHz WAV file

Output:

- Mono 48 kHz audio WAV file

If a directory is passed to `--input`, all `.wav` files directly inside that
directory are processed. Directory traversal is not recursive.