Skip to content

소리를 요청으로 받고 스펙트로그램 이미지로 변환해 모델을 돌리고 결과값을 출력해주는 Backend Server

License

Notifications You must be signed in to change notification settings

CAP-JJANG/CSD-Server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🙌 소개

[ENG]
CSD Server receives the sound as a request and converts it into a spectrogram image to run the model and output the result value.


[KOR]
소리를 요청으로 받고 스펙트로그램 이미지로 변환해 모델을 돌리고 예측값을 출력해주는 CSDServer 입니다.



💪 주요 기능

[ENG]

  1. Take the acoustic byte Array from the client, convert it to an ac file, and convert it to a wav file.
  2. Use the liborasa library to convert the wave file into a spectrogram image in the form of a time-frequency graph.
  3. Apply the converted image to the CSD-Model to extract the alphabetic result value and send a POST response to the client.

[KOR]

  1. client로부터 음향 byteArray를 받아 이를 acc 파일로 변환을 한뒤 wav 파일로 변환을 합니다.
  2. wav 파일을 liborasa 라이브러리를 사용하여 시간-주파수 그래프 형태의 스펙트로그램 이미지로 변환합니다.
  3. 변환된 이미지를 CSD-Model에 적용시켜 알파벳 결과값을 추출하여 client에게 POST 응답을 보냅니다.



🦾 주요 기술

Server - Django

  • PyCharm: IDE
  • Python: 3.9.13
  • Django: 4.2.5
  • Djangorestframework: 3.14.0
  • Librosa: 0.10.1
  • Matplotlib: 3.7.2
  • Numpy: 1.25.2
  • Pillow: 10.0.1
  • Pydub: 0.25.1
  • Torch: 1.13.1
  • Torchvision: 0.14.1



🔗 서비스 아키텍처

Section 2



🔗 디렉터리 구조

CSDServer
├── CSDServer
│   ├── __init__.py
│   ├── asgi.py
│   ├── settings
│   │   ├── __init__.py
│   │   ├── base.py
│   │   ├── development.py
│   │   ├── local.py
│   │   └── production.py
│   ├── urls.py
│   ├── views.py
│   └── wsgi.py
├── __init__.py
├── manage.py
├── requirements
│   ├── base.txt
│   ├── local.txt
│   └── production.txt
└── venv
└── static
  ├── audio
  │   ├── combined.wav
  │   └── silent.wav
  ├── images
  │   └── test.jpg
  └── resnetModel
      └── resnet34.pth



⭐️ 설치 방법

  1. clone [github 리포지토리 주소]

  2. cd CSD-Server/CSDServer

  3. 가상환경 생성

    python -m venv venv
    

    또는

    python3 -m venv venv
    
  4. 가상환경 실행

    • Windows
      venv\Scripts\activate
      
    • macOS 및 Linux
      source venv/bin/activate
      
  5. pip 최신버전으로 업그레이드

    python -m pip install —-upgrade pip
    

    또는

    python3 -m pip install —-upgrade pip
    
  6. 패키지 설치

    pip install -r requirements.txt
    

    또는

    pip3 install -r requirements.txt
    
  7. secrets.json 파일 생성

    CSDServer
     ├── CSDServer
     │   ├── __init__.py
     │   ├── __pycache__
     │   ├── asgi.py
     │   ├── settings
     │   ├── urls.py
     │   ├── views.py
     │   └── wsgi.py
     ├── __init__.py
     ├── manage.py
     ├── requirements
     ├── secrets.json
     └── static

    django 프로젝트를 생성했을 때 settings.py 파일 안에 있는 SECRET_KEY를 가지고 {"SECRET_KEY" : ( secret key 입력 )} 형태로 secrets.json 파일에 작성합니다.

  8. migration

    python manage.py makemigrations
    python manage.py migrate
    

    또는

    python3 manage.py makemigrations
    python3 manage.py migrate
    
  9. 로컬 실행

    python manage.py runserver
    

    또는

    python3 manage.py runserver
    



👏 API ENDPOINT

process_audio : byteArray 받아서 모델돌리고 숫자 예측값 변환

  • URL

    /process_audio/

  • Method

    POST

  • URL Params

    None

  • Data Params

    key value
    ‘recordData’ byteArray
  • Success Response:

    code : 200

    content :

    [
    	{
    		"predicted_alphabet": String,
    	}
    ]



🤖 라이센스

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
OSS Notice sets forth attribution notices for third party software that may be contained in this application.

About

소리를 요청으로 받고 스펙트로그램 이미지로 변환해 모델을 돌리고 결과값을 출력해주는 Backend Server

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages