Skip to content

Commit

Permalink
add global attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
ldzhangyx committed Jul 4, 2023
1 parent 2a23c84 commit 5d92919
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion melodytalk/audiocraft/modules/conditioners.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ def _get_wav_embedding(self, wav):
# avoid 0-size tensors when we are working with null conds
if wav.shape[-1] == 1:
return self.chroma(wav)
# stems = self._get_filtered_wav(wav)
stems = self._get_filtered_wav(wav)
stems = wav
chroma = self.chroma(stems)

Expand Down
20 changes: 19 additions & 1 deletion melodytalk/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import torch
from shutil import copyfile
import torchaudio
from dataclasses import dataclass
import typing as tp

# text2music
from audiocraft.models import MusicGen
Expand All @@ -12,7 +14,7 @@

from utils import *

DURATION = 12
DURATION = 15

# Initialze common models
musicgen_model = MusicGen.get_pretrained('large')
Expand All @@ -21,6 +23,22 @@
musicgen_model_melody = MusicGen.get_pretrained('melody')
musicgen_model_melody.set_generation_params(duration=DURATION)


@dataclass
class GlobalAttributes(object):
# metadata
key: str = None
bpm: int = None
genre: str = None
mood: str = None
instrument: str = None
# text description cache
description: str = None
# tracks cache
mix: torch.Tensor = None
stems: tp.Dict[str, torch.Tensor] = None


class Text2Music(object):
def __init__(self, device):
print("Initializing Text2Music")
Expand Down
1 change: 1 addition & 0 deletions melodytalk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
import openai
import typing as tp
import madmom

openai.api_key = os.getenv("OPENAI_API_KEY")

Expand Down

0 comments on commit 5d92919

Please sign in to comment.