lyrics-transcriber 0.16.2__py3-none-any.whl → 0.16.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lyrics_transcriber/transcriber.py +26 -13
- {lyrics_transcriber-0.16.2.dist-info → lyrics_transcriber-0.16.4.dist-info}/METADATA +2 -1
- {lyrics_transcriber-0.16.2.dist-info → lyrics_transcriber-0.16.4.dist-info}/RECORD +6 -6
- {lyrics_transcriber-0.16.2.dist-info → lyrics_transcriber-0.16.4.dist-info}/LICENSE +0 -0
- {lyrics_transcriber-0.16.2.dist-info → lyrics_transcriber-0.16.4.dist-info}/WHEEL +0 -0
- {lyrics_transcriber-0.16.2.dist-info → lyrics_transcriber-0.16.4.dist-info}/entry_points.txt +0 -0
@@ -14,6 +14,8 @@ from datetime import timedelta
|
|
14
14
|
from .utils import subtitles
|
15
15
|
from typing import List, Optional
|
16
16
|
from openai import OpenAI
|
17
|
+
from tenacity import retry, stop_after_delay, wait_exponential, retry_if_exception_type
|
18
|
+
import requests
|
17
19
|
|
18
20
|
|
19
21
|
class LyricsTranscriber:
|
@@ -536,6 +538,16 @@ class LyricsTranscriber:
|
|
536
538
|
self.outputs["spotify_lyrics_text"] += line["words"].strip() + "\n"
|
537
539
|
f.write(line["words"].strip() + "\n")
|
538
540
|
|
541
|
+
@retry(
|
542
|
+
stop=stop_after_delay(120), # Stop after 2 minutes
|
543
|
+
wait=wait_exponential(multiplier=1, min=4, max=60), # Exponential backoff starting at 4 seconds
|
544
|
+
retry=retry_if_exception_type(requests.exceptions.RequestException), # Retry on request exceptions
|
545
|
+
reraise=True, # Reraise the last exception if all retries fail
|
546
|
+
)
|
547
|
+
def fetch_genius_lyrics(self, genius, title, artist):
|
548
|
+
self.logger.debug(f"fetch_genius_lyrics attempting to fetch lyrics from Genius for {title} by {artist}")
|
549
|
+
return genius.search_song(title, artist)
|
550
|
+
|
539
551
|
def write_genius_lyrics_file(self):
|
540
552
|
if self.genius_api_token and self.song_known:
|
541
553
|
self.logger.debug(f"attempting genius fetch as genius_api_token and song name was set")
|
@@ -556,18 +568,22 @@ class LyricsTranscriber:
|
|
556
568
|
self.logger.debug(f"no cached lyrics found at genius_lyrics_cache_filepath: {genius_lyrics_cache_filepath}, fetching from Genius")
|
557
569
|
genius = lyricsgenius.Genius(self.genius_api_token, verbose=(self.log_level == logging.DEBUG))
|
558
570
|
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
571
|
+
try:
|
572
|
+
song = self.fetch_genius_lyrics(genius, self.title, self.artist)
|
573
|
+
if song is None:
|
574
|
+
self.logger.warning(f'Could not find lyrics on Genius for "{self.title}" by {self.artist}')
|
575
|
+
return
|
576
|
+
lyrics = self.clean_genius_lyrics(song.lyrics)
|
564
577
|
|
565
|
-
|
566
|
-
|
567
|
-
|
578
|
+
self.logger.debug(f"writing clean lyrics to genius_lyrics_cache_filepath: {genius_lyrics_cache_filepath}")
|
579
|
+
with open(genius_lyrics_cache_filepath, "w", encoding="utf-8") as f:
|
580
|
+
f.write(lyrics)
|
568
581
|
|
569
|
-
|
570
|
-
|
582
|
+
self.outputs["genius_lyrics_filepath"] = genius_lyrics_cache_filepath
|
583
|
+
self.outputs["genius_lyrics_text"] = lyrics
|
584
|
+
except requests.exceptions.RequestException as e:
|
585
|
+
self.logger.error(f"Failed to fetch lyrics from Genius after multiple retries: {e}")
|
586
|
+
raise
|
571
587
|
|
572
588
|
def clean_genius_lyrics(self, lyrics):
|
573
589
|
lyrics = lyrics.replace("\\n", "\n")
|
@@ -762,9 +778,6 @@ class LyricsTranscriber:
|
|
762
778
|
if "h264_videotoolbox" in ffmpeg_codes:
|
763
779
|
video_codec = "h264_videotoolbox"
|
764
780
|
self.logger.info(f"video codec set to hardware accelerated h264_videotoolbox")
|
765
|
-
elif "h264_qsv" in ffmpeg_codes:
|
766
|
-
video_codec = "h264_qsv"
|
767
|
-
self.logger.info(f"video codec set to hardware accelerated h264_qsv")
|
768
781
|
|
769
782
|
ffmpeg_cmd += [
|
770
783
|
# Use accompaniment track as audio
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: lyrics-transcriber
|
3
|
-
Version: 0.16.
|
3
|
+
Version: 0.16.4
|
4
4
|
Summary: Automatically create synchronised lyrics files in ASS and MidiCo LRC formats with word-level timestamps, using Whisper and lyrics from Genius and Spotify
|
5
5
|
Home-page: https://github.com/karaokenerds/python-lyrics-transcriber
|
6
6
|
License: MIT
|
@@ -26,6 +26,7 @@ Requires-Dist: openai (>=1,<2)
|
|
26
26
|
Requires-Dist: openai-whisper (>=20231117)
|
27
27
|
Requires-Dist: python-slugify (>=8)
|
28
28
|
Requires-Dist: syrics (>=0)
|
29
|
+
Requires-Dist: tenacity (>=8)
|
29
30
|
Requires-Dist: torch (>=1)
|
30
31
|
Requires-Dist: tqdm (>=4)
|
31
32
|
Requires-Dist: transformers (>=4)
|
@@ -6,13 +6,13 @@ lyrics_transcriber/llm_prompts/llm_prompt_lyrics_correction_gpt_optimised_202311
|
|
6
6
|
lyrics_transcriber/llm_prompts/llm_prompt_lyrics_matching_andrew_handwritten_20231118.txt,sha256=hvk2Vs3M3Q4zGQsiQnXvnpd8wXWfwsudYeqN5qFyNWs,1754
|
7
7
|
lyrics_transcriber/llm_prompts/promptfooconfig.yaml,sha256=O4YxlLV7XSUiSw_1Q9G7ELC2VAbrYUV_N5QxrPbd1jE,3735
|
8
8
|
lyrics_transcriber/llm_prompts/test_data/ABBA-UnderAttack-Genius.txt,sha256=8d-RvZtyINKUlpQLwMi-VD--Y59J-epPt7SZSqjFbPI,1690
|
9
|
-
lyrics_transcriber/transcriber.py,sha256=
|
9
|
+
lyrics_transcriber/transcriber.py,sha256=HHZuWuuja6QGrzdGH2KUe4sB0zuyD2qpTvd5cQ89T_M,49806
|
10
10
|
lyrics_transcriber/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
11
11
|
lyrics_transcriber/utils/ass.py,sha256=b8lnjgXGD1OD1ld_b1xxUmSOf4nSEfz9BpgSkh16R4g,90291
|
12
12
|
lyrics_transcriber/utils/cli.py,sha256=8Poba_9wQw0VmOK73vuK-w-abR9QmO4y4FYDHiAQbc0,6972
|
13
13
|
lyrics_transcriber/utils/subtitles.py,sha256=_WG0pFoZMXcrGe6gbARkC9KrWzFNTMOsiqQwNL-H2lU,11812
|
14
|
-
lyrics_transcriber-0.16.
|
15
|
-
lyrics_transcriber-0.16.
|
16
|
-
lyrics_transcriber-0.16.
|
17
|
-
lyrics_transcriber-0.16.
|
18
|
-
lyrics_transcriber-0.16.
|
14
|
+
lyrics_transcriber-0.16.4.dist-info/LICENSE,sha256=BiPihPDxhxIPEx6yAxVfAljD5Bhm_XG2teCbPEj_m0Y,1069
|
15
|
+
lyrics_transcriber-0.16.4.dist-info/METADATA,sha256=UyHyFqAijs91ClbYa_i_kd-FC2GDztiLYVqsmN_yuFo,5805
|
16
|
+
lyrics_transcriber-0.16.4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
17
|
+
lyrics_transcriber-0.16.4.dist-info/entry_points.txt,sha256=lh6L-iR5CGELaNcouDK94X78eS5Ua_tK9lI4UEkza-k,72
|
18
|
+
lyrics_transcriber-0.16.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|
{lyrics_transcriber-0.16.2.dist-info → lyrics_transcriber-0.16.4.dist-info}/entry_points.txt
RENAMED
File without changes
|