Skip to content

Commit

Permalink
working inference example
Browse files Browse the repository at this point in the history
  • Loading branch information
lucidrains committed Feb 2, 2023
1 parent 8a66cce commit c40aee3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,17 @@ wavs = torch.randn(2, 1024)
conds = quantizer(wavs = wavs, namespace = 'semantic') # (2, 8, 1024) - 8 is number of quantizers
```

After much training, you will pass your finetuned or trained-from-scratch `AudioLM` and `MuLaN` wrapped in `MuLaNEmbedQuantizer` to the `MusicLM`

```python
musiclm = MusicLM(
audio_lm = audio_lm,
mulan_embed_quantizer = mulan_embed_quantizer
)

music = musiclm(['the crystalline sounds of the piano in a ballroom']) # torch.Tensor
```

## Todo

- [x] mulan seems to be using decoupled contrastive learning, offer that as an option
Expand Down
6 changes: 3 additions & 3 deletions musiclm_pytorch/musiclm_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ def forward(
self.eval()

texts = tokenizer.tokenize(raw_texts)
cond_tokens = self.mulan_embed_quantizer(texts = texts)

wavs = self.audio_lm.generate(cond_tokens = cond_tokens, **audio_lm_kwargs)
return wavs
text_embeds = self.mulan_embed_quantizer(texts = texts)

return self.audio_lm(text_embeds = text_embeds, **audio_lm_kwargs)
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
setup(
name = 'musiclm-pytorch',
packages = find_packages(exclude=[]),
version = '0.0.3',
version = '0.0.4',
license='MIT',
description = 'MusicLM - AudioLM + Audio CLIP to text to music synthesis',
author = 'Phil Wang',
Expand All @@ -19,7 +19,7 @@
'contrastive learning'
],
install_requires=[
'audiolm-pytorch',
'audiolm-pytorch>=0.8.1',
'beartype',
'einops>=0.4',
'vector-quantize-pytorch>=1.0.0',
Expand Down

0 comments on commit c40aee3

Please sign in to comment.