test-commit
This commit is contained in:
parent
e75b57b9eb
commit
f2eb3c05bc
53
server.py
53
server.py
@ -4,7 +4,6 @@ from scipy.io import wavfile
|
||||
import numpy as np
|
||||
import librosa
|
||||
from Utils import ProceesAudio
|
||||
import pyrebase
|
||||
import soundfile as sf
|
||||
import datetime
|
||||
from flask_jwt_extended import JWTManager, jwt_required, create_access_token, get_jwt_identity
|
||||
@ -14,38 +13,38 @@ app.config['MAX_CONTENT_LENGTH'] = 100 * 1024 * 1024 # 16 MB limit
|
||||
|
||||
|
||||
# Firebase configuration
|
||||
firebase_config = {
|
||||
"apiKey": "AIzaSyBqDZlqD7UOBvt2zsk9OLWKH1Lc3_f_VJM",
|
||||
"authDomain": "modifier-4088b.firebaseapp.com",
|
||||
"projectId": "modifier-4088b",
|
||||
"storageBucket": "modifier-4088b.appspot.com",
|
||||
"messagingSenderId": "237119475630",
|
||||
"appId": "1:237119475630:web:6c96c38c61285f5fcb823f",
|
||||
"measurementId": "G-6CWLQMT2Q3",
|
||||
"databaseURL": "https://modifier-4088b.firebaseio.com",
|
||||
}
|
||||
# firebase_config = {
|
||||
# "apiKey": "AIzaSyBqDZlqD7UOBvt2zsk9OLWKH1Lc3_f_VJM",
|
||||
# "authDomain": "modifier-4088b.firebaseapp.com",
|
||||
# "projectId": "modifier-4088b",
|
||||
# "storageBucket": "modifier-4088b.appspot.com",
|
||||
# "messagingSenderId": "237119475630",
|
||||
# "appId": "1:237119475630:web:6c96c38c61285f5fcb823f",
|
||||
# "measurementId": "G-6CWLQMT2Q3",
|
||||
# "databaseURL": "https://modifier-4088b.firebaseio.com",
|
||||
# }
|
||||
|
||||
firebase = pyrebase.initialize_app(firebase_config)
|
||||
storage = firebase.storage()
|
||||
# firebase = pyrebase.initialize_app(firebase_config)
|
||||
# storage = firebase.storage()
|
||||
|
||||
@app.route('/process_and_upload', methods=['POST'])
|
||||
|
||||
def upload_to_firebase(processed_data, userId):
|
||||
# Create an in-memory bytes buffer
|
||||
buffer = io.BytesIO()
|
||||
# def upload_to_firebase(processed_data, userId):
|
||||
# # Create an in-memory bytes buffer
|
||||
# buffer = io.BytesIO()
|
||||
|
||||
# Write processed data to the buffer as a WAV file
|
||||
sf.write(buffer, processed_data, 44100, format='WAV')
|
||||
buffer.seek(0) # Rewind the buffer
|
||||
# # Write processed data to the buffer as a WAV file
|
||||
# sf.write(buffer, processed_data, 44100, format='WAV')
|
||||
# buffer.seek(0) # Rewind the buffer
|
||||
|
||||
# Upload the buffer to Firebase Storage
|
||||
storage_path = f'uploads/processed_audio_{userId}.wav'
|
||||
storage.child(storage_path).put(buffer, f'processed_audio_{userId}.wav')
|
||||
# # Upload the buffer to Firebase Storage
|
||||
# storage_path = f'uploads/processed_audio_{userId}.wav'
|
||||
# storage.child(storage_path).put(buffer, f'processed_audio_{userId}.wav')
|
||||
|
||||
# Get the URL of the uploaded file
|
||||
file_url = storage.child(storage_path).get_url(None)
|
||||
# # Get the URL of the uploaded file
|
||||
# file_url = storage.child(storage_path).get_url(None)
|
||||
|
||||
return file_url
|
||||
# return file_url
|
||||
|
||||
|
||||
def int16_to_float32(samples):
|
||||
@ -65,7 +64,7 @@ def process_audio_bytes(audio_bytes):
|
||||
pa = ProceesAudio()
|
||||
|
||||
processed_data = pa.perform_modulation(data=data, sr=sample_rate, index=0)
|
||||
file_url = upload_to_firebase(processed_data=processed_data, userId="parth")
|
||||
# file_url = upload_to_firebase(processed_data=processed_data, userId="parth")
|
||||
arr_to_show = []
|
||||
|
||||
acc_factor = int(len(processed_data)/150)
|
||||
@ -76,7 +75,7 @@ def process_audio_bytes(audio_bytes):
|
||||
for i in range(len(arr_to_show)):
|
||||
arr_to_show[i] = float(arr_to_show[i])
|
||||
|
||||
return jsonify({"file_url": file_url, "array": arr_to_show})
|
||||
return jsonify({"file_url": "", "array": arr_to_show})
|
||||
|
||||
@app.route('/modify', methods=['POST'])
|
||||
def modify():
|
||||
|
Loading…
Reference in New Issue
Block a user