File size: 2,297 Bytes
36ad38b
 
 
601ee2d
36ad38b
 
 
a9c5f00
36ad38b
96b7f88
 
 
 
36ad38b
 
 
 
 
 
 
 
 
 
 
 
 
601ee2d
 
 
 
 
 
 
61961ee
6d58e06
61961ee
 
601ee2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import streamlit as st
from streamlit_star_rating import st_star_rating
st.set_page_config(initial_sidebar_state="collapsed")
from mega import Mega
import glob
import shutil
import sys
import os
sys.path.append('../../')
sys.path.append('../')
sys.path.append('./')
spectrograms = glob.glob(os.path.join(os.getcwd(),"ui/temp*.npy"))
generated_songs = glob.glob(os.path.join(os.getcwd(),"ui/temp*.wav"))

st.markdown("# Original Song")
for s in st.session_state['song_list']:
    st.markdown(f"### {s.split('/')[-1].split('.')[0]}")
    st.audio(s, format='audio/wav')
st.markdown("# Generated Song")
st.audio(generated_songs[0], format='audio/wav')
rating = st_star_rating(label="rating", maxValue=10, defaultValue=3)


submit_rating = st.button("Submit Rating")

if submit_rating:
    # shutil.copy(generated_songs[0],f"../DataSet/Song/srija_{st.session_state['model_name']}_{st.session_state['song_name']}_{st.session_state['similarity']}_{rating}.wav")
    # shutil.copy(spectrograms[0],f"../DataSet/Spec/srija_{st.session_state['model_name']}_{st.session_state['song_name']}_{st.session_state['similarity']}_{rating}.npy")
    # st.switch_page("app.py")

    
    # uplaod to mega
    mega = Mega()
    mega_user_name = os.environ.get('MEGA_USERNAME')
    mega_password = os.environ.get('MEGA_PASSWORD')
    print("hi")
    mega._login_user(mega_user_name,mega_password)
    
    user = st.session_state['user_id']  # Assuming 'srija' is the user
    model_name = st.session_state['model_name']
    song_name = st.session_state['song_name']
    similarity = st.session_state['similarity']
    
    # Construct the dynamic filenames
    dynamic_song_name = f"{user}_{model_name}_{song_name}_{similarity}_{rating}.wav"
    dynamic_spec_name = f"{user}_{model_name}_{song_name}_{similarity}_{rating}.npy"
    
    folder = mega.find('orpheus_data')
    
    # Rename and upload the generated song
    generated_song_path = generated_songs[0]
    mega.upload(generated_song_path, folder[0], dest_filename=dynamic_song_name)

    # Rename and upload the spectrogram
    spectrogram_path = spectrograms[0]
    mega.upload(spectrogram_path, folder[0], dest_filename=dynamic_spec_name)

    # Provide user feedback (optional)
    st.success("Files uploaded successfully!")
    st.switch_page("app.py")