fffiloni commited on
Commit
101e568
·
verified ·
1 Parent(s): 75166b1

Update inference/infer.py

Browse files
Files changed (1) hide show
  1. inference/infer.py +9 -18
inference/infer.py CHANGED
@@ -121,33 +121,24 @@ stage1_output_set = []
121
  # genre tags support instrumental,genre,mood,vocal timbr and vocal gender
122
  # all kinds of tags are needed
123
  # Ensure files exist
124
- if not os.path.exists(args.genre_txt):
125
- raise FileNotFoundError(f"Genre file not found: {args.genre_txt}")
126
- if not os.path.exists(args.lyrics_txt):
127
- raise FileNotFoundError(f"Lyrics file not found: {args.lyrics_txt}")
128
-
129
- # Read genre file safely
130
  with open(args.genre_txt, encoding="utf-8") as f:
131
  genres = f.read().strip()
132
 
133
- # Read lyrics safely and debug format
134
  with open(args.lyrics_txt, encoding="utf-8") as f:
135
  raw_lyrics = f.read()
136
 
137
- # Debugging: Check raw file content
138
- print("DEBUG: Lyrics before processing:", repr(raw_lyrics))
139
-
140
- # Normalize lyrics format
141
- normalized_lyrics = "\n\n".join([block.strip() for block in raw_lyrics.split("\n\n")])
142
 
143
- # Process lyrics
144
- lyrics = split_lyrics(normalized_lyrics)
145
 
146
- # Debugging: Check lyrics after splitting
147
- print("DEBUG: Lyrics after split_lyrics:", repr(lyrics))
148
-
149
- # Prepare prompt
150
  full_lyrics = "\n".join(lyrics)
 
 
151
  prompt_texts = [f"Generate music from the given lyrics segment by segment.\n[Genre] {genres}\n{full_lyrics}"]
152
  prompt_texts += lyrics
153
 
 
121
  # genre tags support instrumental,genre,mood,vocal timbr and vocal gender
122
  # all kinds of tags are needed
123
  # Ensure files exist
124
+ # Read genre file with UTF-8 encoding
 
 
 
 
 
125
  with open(args.genre_txt, encoding="utf-8") as f:
126
  genres = f.read().strip()
127
 
128
+ # Read lyrics file with UTF-8 encoding
129
  with open(args.lyrics_txt, encoding="utf-8") as f:
130
  raw_lyrics = f.read()
131
 
132
+ # Format lyrics content and ensure proper newline spacing between blocks
133
+ formatted_lyrics = "\n\n".join([block.strip() for block in raw_lyrics.split("\n\n")])
 
 
 
134
 
135
+ # Now, split the formatted lyrics into blocks
136
+ lyrics = split_lyrics(formatted_lyrics)
137
 
138
+ # Join all lyrics into one single string for the full lyrics
 
 
 
139
  full_lyrics = "\n".join(lyrics)
140
+
141
+ # Prepare the prompt with genre and full lyrics
142
  prompt_texts = [f"Generate music from the given lyrics segment by segment.\n[Genre] {genres}\n{full_lyrics}"]
143
  prompt_texts += lyrics
144