From ebc5b59e6d35b89ce483bf1c3b56ce8df9fcbad6 Mon Sep 17 00:00:00 2001 From: minjunj Date: Tue, 21 May 2024 19:43:56 +0900 Subject: [PATCH] update : start v1.0 --- .DS_Store | Bin 0 -> 6148 bytes .github/workflows/build_and_deploy.yaml | 64 +++++++++ .gitignore | 4 + .streamlit/config.toml | 2 + Dockerfile | 22 +++ __pycache__/main.cpython-311.pyc | Bin 0 -> 847 bytes play.py | 77 +++++++++++ recoded_sample/.DS_Store | Bin 0 -> 6148 bytes .../recoded_sample/canon_chords.lab | 8 ++ recoded_sample/recoded_sample/dont_lazy.lab | 8 ++ recoded_sample/recoded_sample/honey_jet.lab | 9 ++ .../recoded_sample/honey_jet_pre_skip.lab | 9 ++ recoded_sample/recoded_sample/line.txt | 11 ++ recoded_sample/recoded_sample/solo.lab | 1 + requirements.txt | 106 +++++++++++++++ session.py | 127 ++++++++++++++++++ streamlit.py | 20 +++ 17 files changed, 468 insertions(+) create mode 100644 .DS_Store create mode 100644 .github/workflows/build_and_deploy.yaml create mode 100644 .gitignore create mode 100644 .streamlit/config.toml create mode 100644 Dockerfile create mode 100644 __pycache__/main.cpython-311.pyc create mode 100644 play.py create mode 100644 recoded_sample/.DS_Store create mode 100644 recoded_sample/recoded_sample/canon_chords.lab create mode 100644 recoded_sample/recoded_sample/dont_lazy.lab create mode 100644 recoded_sample/recoded_sample/honey_jet.lab create mode 100644 recoded_sample/recoded_sample/honey_jet_pre_skip.lab create mode 100644 recoded_sample/recoded_sample/line.txt create mode 100644 recoded_sample/recoded_sample/solo.lab create mode 100644 requirements.txt create mode 100644 session.py create mode 100644 streamlit.py diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..0877b455487f95b610f0df9d370da8940752b792 GIT binary patch literal 6148 zcmeHKL23gr3>>vN1OiEpJ^Bm%feFbA`hc{}ZlRE}B}?vpdPkNvWa+l2Qc96P9@&;; z@4(s?0NI?IdtePiT>h{?tQ@>zoMaD@4tO% z`onYA9rr8@Jv!Lb5`d`B=qj|eme82wm>r8DXDDK!L<!;7tyEaiDsVeGM)S%EFJp$O#bL6g0+I&)*e%Y}YY8D-@;ly|d MR6?Q&27ZBo4pF literal 0 HcmV?d00001 diff --git a/.github/workflows/build_and_deploy.yaml b/.github/workflows/build_and_deploy.yaml new file mode 100644 index 0000000..116e1dd --- /dev/null +++ b/.github/workflows/build_and_deploy.yaml @@ -0,0 +1,64 @@ +name: Build and Push Docker Image + +on: + push: + branches: + - main +permissions: + contents: write + +jobs: + build: + runs-on: ubuntu-latest + outputs: + IMAGE_TAG: ${{ github.run_number }} + + steps: + - name: Check out code + uses: actions/checkout@v3 + + - name: Log in to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push Docker image + uses: docker/build-push-action@v3 + env: + IMAGE_TAG: ${{ github.run_number }} + with: + context: . + push: true + tags: minjuncho/blms-fe:${{ env.IMAGE_TAG }} + id: docker_build + + - name: Output the image tag + run: echo "IMAGE_TAG=${{ steps.docker_build.outputs.digest }}" >> $GITHUB_ENV + + deploy: + needs: build + runs-on: ubuntu-latest + steps: + - name: Check out infra-ops repository + uses: actions/checkout@v2 + with: + repository: "keiburu-Tai/infra-ops" + ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} + fetch-depth: 0 + + - name: List directory contents + run: ls -R + + - name: Update Kubernetes Manifests + env: + IMAGE_TAG: ${{ github.run_number }} + run: | + sed -i 's|image:.*|image: minjuncho/blms-fe:${{ env.IMAGE_TAG }}|' service/blms-fe/blms-fe.yaml + + - name: commit and push + run: | + git config user.name github-actions + git config user.email github-actions@github.com + git commit -am "Deploying image ${{ env.IMAGE_TAG }}" + git push origin main diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dd128cf --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.env + +*.mid +*.wav \ No newline at end of file diff --git a/.streamlit/config.toml b/.streamlit/config.toml new file mode 100644 index 0000000..ef393e3 --- /dev/null +++ b/.streamlit/config.toml @@ -0,0 +1,2 @@ +[server] +baseUrlPath = "blms" \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e98e1e0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM python:3.9-slim + +WORKDIR /app + +COPY . . + +RUN apt-get update && apt-get install -y \ + build-essential \ + curl \ + software-properties-common \ + git \ + libasound2-dev \ + libsndfile1 \ + portaudio19-dev \ + && rm -rf /var/lib/apt/lists/* + +RUN pip install --upgrade pip +RUN pip install st-pages sounddevice soundfile streamlit streamlit_webrtc bokeh streamlit-bokeh-events + +EXPOSE 8501 + +ENTRYPOINT ["streamlit", "run", "streamlit.py", "--server.port=8501", "--server.address=0.0.0.0"] \ No newline at end of file diff --git a/__pycache__/main.cpython-311.pyc b/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4c779a78cf52b8b445928593b474d497907edd68 GIT binary patch literal 847 zcmZ`%&1(}u6rYdX%~w+@J*3j4_E2bZ(ESHQ=tcArlv0Yhl-QYsmHkL(Hiv43R04YJ ztsXq&R4v7S!}AI~$lxL1$y=lcAt&G4B-I3b%)EJT_V<48H;?^TEanN=_ut!1n-cN^ zlc{AV!Sxpi&WIp_`Xr!rN-<_W3wWJV!iePOfViC2k-8OtfVq4oF=6IA@)@i#cBbnaL&32u1f|B%cpxup^{h?g?(Qxxn3*- z?Y_ce-xIHECNl{QJv=~>Q$w+-VB|a_$K;p_`hkIDR=Z#d8>mHeC|50k(^$T~t_pBW zL?O4j1v$bsfU)SxIKsfUG97Yv2^StrM^3 zb@|XC%zj&XQ+l_2Qtp+9jMB9s0r!g&wm7}WPC!X+^(!r3(G<6ZxUEy29`8H-olhJ6 UXIFRJH2>?6s4`QMeoM#l2eOH@LjV8( literal 0 HcmV?d00001 diff --git a/play.py b/play.py new file mode 100644 index 0000000..19c4c1d --- /dev/null +++ b/play.py @@ -0,0 +1,77 @@ +import streamlit as st +import pandas as pd +import numpy as np +from st_pages import Page, Section, show_pages, add_page_title +import time + +import sounddevice as sd +import soundfile as sf + + +st.title('''Playing Guitar!''') + +def list_devices(): + #print("Available audio devices:") + name_dict = {} + devices = sd.query_devices() + i = 0 + for index, device in enumerate(devices): + #print(index, device['name'], ", Core Audio (", device['max_input_channels'], "in,", device['max_output_channels'], "out)") + name_dict[device['name']] = i + i += 1 + #print(name_dict) + return name_dict + +def record_audio(device_index, duration=10, sample_rate=44100): + try: + device_info = sd.query_devices(device_index) + audio_data = sd.rec(int(duration * sample_rate), samplerate=sample_rate, channels=2, device=device_index, dtype='float32') + sd.wait() # Wait until recording is finished + # Save recorded data as a WAV file + output_file = 'recoded_sample/first.wav' + sf.write(output_file, audio_data, sample_rate) + except Exception as e: + print(f"An error occurred: {e}") + st.error(f'An error occurred: {e}') + + +with st.container(border=True): + try: + ele = list_devices() + input_option = st.selectbox( + "Please Select Input Device.", + (ele.keys())) + + output_option = st.selectbox( + "Please Select Output Device", + (ele.keys())) + + time_duration = st.slider("How long recode?", 0, 20, 10) + col1, col2 = st.columns([0.2, 1.4]) + with col1: + if st.button("Recode"): + st.session_state["Recode"] = True + with col2: + if st.button("Save"): + st.session_state["Save"] = True + if 'Recode' in st.session_state and st.session_state['Recode']: + st.write('1') + time.sleep(1) + st.write('2') + time.sleep(1) + st.write('3') + time.sleep(0.5) + st.write("ready") + time.sleep(0.5) + st.write('start!!!') + with st.spinner('recording...'): + + record_audio(ele.get(input_option), duration=time_duration, sample_rate=44100) + st.audio("recoded_sample/first.wav", format="audio/mpeg", loop=False) + st.session_state['Recode'] = False + if 'Save' in st.session_state and st.session_state['Save']: + st.write("Shot Auto Chord") + st.success('This is a success message!') + st.session_state['Save'] = False + except: + pass \ No newline at end of file diff --git a/recoded_sample/.DS_Store b/recoded_sample/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..8f581d13e751ea4f61d91dc5fa47e1f58ce0efad GIT binary patch literal 6148 zcmeHKIZgvX5Ud6VmXIumg!2V{u(HexcmRjjL`I9SoNvUtc$%w^WVH}kBv!T5Q!_nX zGnxvvw*lDZ)IR`g086?fzI~XR@4L_JrXoh9^Nb#Q`ZJDron`+XaPA6U%@)a7<)`W=SO`)vCp?q%+