Zacharytrackmaster commited on
Commit
2176796
·
verified ·
1 Parent(s): a5794b9

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -75
app.py DELETED
@@ -1,75 +0,0 @@
1
- import streamlit as st
2
- from lyrics_translator import LyricsTranslator
3
-
4
-
5
- config = {"GENIUS_ACCESS_TOKEN": st.secrets["GENIUS_ACCESS_TOKEN"]}
6
-
7
-
8
- info = """
9
- The "Lyrics Translator" downloads lyrics from Genius and uses 🤗 Hugging Face to translate the lyrics into a language of your choice!
10
- """
11
-
12
- title = "🎵 Lyrics Translator"
13
-
14
- language_mapper = {
15
- "German": "de",
16
- "Swedish": "sv",
17
- "Italian": "it",
18
- "French": "fr",
19
- "Finnish": "fi",
20
- }
21
-
22
- st.title(title)
23
- st.info(info, icon="ℹ️")
24
-
25
-
26
- with st.sidebar:
27
- st.subheader("Automated lyrics translation!")
28
-
29
- song = st.text_input("Choose a track:", "One More Time")
30
- artist = st.text_input("Choose an artist:", "Daft Punk")
31
- language_original = st.radio("Choose a language:", tuple(language_mapper.keys()))
32
-
33
- is_button_results = st.button("Translate!")
34
-
35
-
36
- language = language_mapper.get(language_original, None)
37
-
38
-
39
- @st.cache_resource
40
- def load_translator(language):
41
- translator = LyricsTranslator(language=language, config=config)
42
- return translator
43
-
44
-
45
- if is_button_results:
46
- with st.spinner("Download the model this can take a while..."):
47
- translator = load_translator(language)
48
-
49
- col1, col2 = st.columns(2)
50
-
51
- with col1.container():
52
- with st.spinner("Fetching the song lyrics, this can take a while..."):
53
- try:
54
- lyrics = translator.get_song_lyrics(song, artist)
55
- is_success = True
56
- except ValueError:
57
- col1.error("No lyrics found for this song!")
58
-
59
- if is_success:
60
- col1.success(f"Found lyrics for '{song}' by '{artist}'!")
61
- col1.text(lyrics)
62
-
63
- with col2.container():
64
- with st.spinner("Song is being translated, this can take a while..."):
65
- try:
66
- text = translator.get_song_translation(song, artist)
67
- is_success = True
68
- except ValueError:
69
- col2.error("No lyrics found for this song!")
70
-
71
- if is_success:
72
- col2.success(
73
- f"Translated lyrics for '{song}' by '{artist}' to '{language_original}'!"
74
- )
75
- col2.text(text)