Spaces:
Sleeping
Sleeping
Rob Learsch commited on
Commit ·
d7ed08f
1
Parent(s): f9264fa
Update app.py
Browse files
app.py
CHANGED
|
@@ -48,20 +48,23 @@ def load_lyrics(filename):
|
|
| 48 |
#return [line for line in lyrics]
|
| 49 |
|
| 50 |
def artist_response(gemma_response, artist):
|
| 51 |
-
encoded_gemma = encoder_model.encode(gemma_response)
|
| 52 |
if artist == "Radiohead":
|
| 53 |
artist_embeddings = radiohead_embeddings
|
|
|
|
| 54 |
if artist == "Kendrick Lamar":
|
| 55 |
artist_embeddings = kendrick_embeddings
|
|
|
|
| 56 |
if artist == "Grateful Dead":
|
| 57 |
artist_embeddings = grateful_dead_embeddings
|
|
|
|
| 58 |
|
|
|
|
| 59 |
similarity_result = encoder_model.similarity(
|
| 60 |
encoded_gemma,
|
| 61 |
artist_embeddings,
|
| 62 |
)
|
| 63 |
result_max_index = np.argmax(similarity_result)
|
| 64 |
-
lyric_response =
|
| 65 |
return lyric_response
|
| 66 |
|
| 67 |
radiohead_lyrics = load_lyrics("radiohead_lyrics.txt")
|
|
@@ -115,10 +118,7 @@ def chat_with_musician(user_input, history, artist):
|
|
| 115 |
|
| 116 |
history.append({"role": "user", "content": user_input})
|
| 117 |
history.append({"role": "assistant", "content": gemma_response})
|
| 118 |
-
|
| 119 |
-
lyric_response = find_most_relevant_lyric(stitched_radiohead_lyrics,
|
| 120 |
-
gemma_response)
|
| 121 |
-
return lyric_response
|
| 122 |
lyric_response = artist_response(gemma_response, artist)
|
| 123 |
if artist == "Google Gemma":
|
| 124 |
lyric_response = gemma_response
|
|
|
|
| 48 |
#return [line for line in lyrics]
|
| 49 |
|
| 50 |
def artist_response(gemma_response, artist):
|
|
|
|
| 51 |
if artist == "Radiohead":
|
| 52 |
artist_embeddings = radiohead_embeddings
|
| 53 |
+
lyric_list = stitched_radiohead_lyrics
|
| 54 |
if artist == "Kendrick Lamar":
|
| 55 |
artist_embeddings = kendrick_embeddings
|
| 56 |
+
lyric_list = stitched_kendrick_lyrics
|
| 57 |
if artist == "Grateful Dead":
|
| 58 |
artist_embeddings = grateful_dead_embeddings
|
| 59 |
+
lyric_list = stitched_grateful_dead_lyrics
|
| 60 |
|
| 61 |
+
encoded_gemma = encoder_model.encode(gemma_response)
|
| 62 |
similarity_result = encoder_model.similarity(
|
| 63 |
encoded_gemma,
|
| 64 |
artist_embeddings,
|
| 65 |
)
|
| 66 |
result_max_index = np.argmax(similarity_result)
|
| 67 |
+
lyric_response = lyric_list[result_max_index]
|
| 68 |
return lyric_response
|
| 69 |
|
| 70 |
radiohead_lyrics = load_lyrics("radiohead_lyrics.txt")
|
|
|
|
| 118 |
|
| 119 |
history.append({"role": "user", "content": user_input})
|
| 120 |
history.append({"role": "assistant", "content": gemma_response})
|
| 121 |
+
|
|
|
|
|
|
|
|
|
|
| 122 |
lyric_response = artist_response(gemma_response, artist)
|
| 123 |
if artist == "Google Gemma":
|
| 124 |
lyric_response = gemma_response
|