Skip to content

Commit

Permalink
Adjusted output filename to match karaoke generator project
Browse files Browse the repository at this point in the history
  • Loading branch information
beveradb committed Jul 9, 2023
1 parent 722c973 commit 29116dc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions lyrics_transcriber/transcriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def write_spotify_lyrics_file(self):
self.logger.warning(f"skipping spotify fetch as not all spotify params were set")
return

spotify_lyrics_cache_filepath = os.path.join(self.cache_dir, self.get_song_slug() + "-spotify.json")
spotify_lyrics_cache_filepath = os.path.join(self.cache_dir, "lyrics-" + self.get_song_slug() + "-spotify.json")

if os.path.isfile(spotify_lyrics_cache_filepath):
self.logger.debug(f"found existing file at spotify_lyrics_cache_filepath, reading: {spotify_lyrics_cache_filepath}")
Expand Down Expand Up @@ -157,7 +157,7 @@ def write_genius_lyrics_file(self):
self.logger.warning(f"skipping genius fetch as not all genius params were set")
return

genius_lyrics_cache_filepath = os.path.join(self.cache_dir, self.get_song_slug() + "-genius.txt")
genius_lyrics_cache_filepath = os.path.join(self.cache_dir, "lyrics-" + self.get_song_slug() + "-genius.txt")

if os.path.isfile(genius_lyrics_cache_filepath):
self.logger.debug(f"found existing file at genius_lyrics_cache_filepath, reading: {genius_lyrics_cache_filepath}")
Expand Down Expand Up @@ -269,16 +269,16 @@ def transcribe(self):

def get_cache_filepath(self, extension):
filename = os.path.split(self.audio_filepath)[1]
filename_slug = slugify.slugify(filename)
filename_slug = slugify.slugify(filename, lowercase=False)
hash_value = self.get_file_hash(self.audio_filepath)
cache_filepath = os.path.join(self.cache_dir, filename_slug + "_" + hash_value + extension)
self.logger.debug(f"get_cache_filepath returning cache_filepath: {cache_filepath}")
return cache_filepath

def get_song_slug(self):
artist_slug = slugify.slugify(self.artist)
title_slug = slugify.slugify(self.title)
return artist_slug + "_" + title_slug
artist_slug = slugify.slugify(self.artist, lowercase=False)
title_slug = slugify.slugify(self.title, lowercase=False)
return artist_slug + "-" + title_slug

def get_file_hash(self, filepath):
return hashlib.md5(open(filepath, "rb").read()).hexdigest()
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "lyrics-transcriber"
version = "0.6.2"
version = "0.6.3"
description = "Automatically create synchronised lyrics files in ASS and MidiCo LRC formats with word-level timestamps, using Whisper and lyrics from Genius and Spotify"
authors = ["Andrew Beveridge <[email protected]>"]
license = "MIT"
Expand Down

0 comments on commit 29116dc

Please sign in to comment.