Skip to content

Commit

Permalink
Updated dependencies, fixed dupe space char in LRC
Browse files Browse the repository at this point in the history
  • Loading branch information
beveradb committed Sep 17, 2024
1 parent 10c0929 commit 0291df1
Show file tree
Hide file tree
Showing 3 changed files with 743 additions and 607 deletions.
12 changes: 10 additions & 2 deletions lyrics_transcriber/transcriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,13 @@ def write_corrected_lyrics_data_file(self):
self.outputs["corrected_lyrics_data_dict"] = corrected_lyrics_data_dict
return

reference_lyrics = self.outputs.get("genius_lyrics_text") or self.outputs.get("spotify_lyrics_text")

if not reference_lyrics:
self.logger.warning("No reference lyrics found from Genius or Spotify. Skipping LLM correction.")
self.outputs["corrected_lyrics_data_dict"] = self.outputs["transcription_data_dict"]
return

self.logger.debug(
f"no cached lyrics found at corrected_lyrics_data_json_cache_filepath: {corrected_lyrics_data_json_cache_filepath}, attempting to run correction using LLM"
)
Expand All @@ -317,7 +324,6 @@ def write_corrected_lyrics_data_file(self):
with open(self.llm_prompt_correction, "r") as file:
system_prompt_template = file.read()

reference_lyrics = self.outputs["genius_lyrics_text"] or self.outputs["spotify_lyrics_text"]
system_prompt = system_prompt_template.replace("{{reference_lyrics}}", reference_lyrics)

# TODO: Test if results are cleaner when using the vocal file from a background vocal audio separation model
Expand Down Expand Up @@ -639,7 +645,9 @@ def write_midico_lrc_file(self):
for i, word in enumerate(segment["words"]):
start_time = self.format_time_lrc(word["start"])
if i != len(segment["words"]) - 1:
word["text"] += " "
if not word["text"].endswith(" "):
self.logger.debug(f"word '{word['text']}' does not end with a space, adding one")
word["text"] += " "
line = "[{}]1:{}{}\n".format(start_time, "/" if i == 0 else "", word["text"])
f.write(line)

Expand Down
Loading

0 comments on commit 0291df1

Please sign in to comment.