some tests
This commit is contained in:
@ -10,8 +10,8 @@
|
||||
"output_device": {
|
||||
"channels": 2,
|
||||
"default_samplerate": 48000,
|
||||
"index": 45,
|
||||
"name": "VM to Discord (VB-Audio Voicemeeter VAIO)"
|
||||
"index": 44,
|
||||
"name": "VM to Headset (VB-Audio Voicemeeter VAIO)"
|
||||
},
|
||||
"http_port": 5010
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -28,6 +28,8 @@ class AudioIO:
|
||||
self.recordings_dir = "recordings"
|
||||
|
||||
sd.default.latency = 'low'
|
||||
|
||||
self.socket = None
|
||||
|
||||
self.in_stream = sd.InputStream(
|
||||
callback=self.record_callback
|
||||
|
||||
@ -14,13 +14,22 @@ from routes.recording import recording_bp
|
||||
from routes.device import device_bp
|
||||
from routes.metadata import metadata_bp
|
||||
from routes.settings import settings_bp
|
||||
from flask_socketio import SocketIO
|
||||
from flask_socketio import SocketIO, emit
|
||||
import threading
|
||||
|
||||
app = Flask(__name__)
|
||||
CORS(app)
|
||||
# socketio = SocketIO(app, cors_allowed_origins="*")
|
||||
# CORS(socketio)
|
||||
socketio = SocketIO(app, cors_allowed_origins="*")
|
||||
|
||||
@socketio.on('connect')
|
||||
def handle_connect():
|
||||
print("Client connected")
|
||||
emit('full_data', MetaDataManager().collections)
|
||||
|
||||
@socketio.on('record_clip')
|
||||
def record_clip(data):
|
||||
io = AudioIO()
|
||||
io.save_last_n_seconds();
|
||||
|
||||
def main():
|
||||
# Create argument parser
|
||||
@ -36,6 +45,9 @@ def main():
|
||||
args = parser.parse_args()
|
||||
audio_manager = WindowsAudioManager()
|
||||
settings = SettingsManager()
|
||||
meta = MetaDataManager()
|
||||
|
||||
|
||||
|
||||
# Ensure save path exists
|
||||
os.makedirs(settings.get_settings('save_path'), exist_ok=True)
|
||||
@ -43,13 +55,18 @@ def main():
|
||||
|
||||
io = AudioIO()
|
||||
io.start_recording()
|
||||
|
||||
# settings.socket = socketio
|
||||
io.socket = socketio
|
||||
meta.socket = socketio
|
||||
|
||||
# Register blueprints
|
||||
app.register_blueprint(recording_bp)
|
||||
app.register_blueprint(device_bp)
|
||||
app.register_blueprint(metadata_bp)
|
||||
app.register_blueprint(settings_bp)
|
||||
app.run(host='127.0.0.1', port=settings.get_settings('http_port'), debug=False, use_reloader=True)
|
||||
# socketio.run(app, host='127.0.0.1', port=args.osc_port, debug=False, use_reloader=True)
|
||||
# app.run(host='127.0.0.1', port=settings.get_settings('http_port'), debug=False, use_reloader=True)
|
||||
socketio.run(app, host='127.0.0.1', port=settings.get_settings('http_port'), debug=False, use_reloader=True)
|
||||
|
||||
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@ class MetaDataManager:
|
||||
cls._instance.init()
|
||||
return cls._instance
|
||||
def init(self):
|
||||
self.socket = None
|
||||
# read metadata file from executing directory
|
||||
self.metadata_file = os.path.join(os.getcwd(), "metadata.json")
|
||||
if os.path.exists(self.metadata_file):
|
||||
@ -93,6 +94,8 @@ class MetaDataManager:
|
||||
raise ValueError("New order contains clips that do not exist in the collection.")
|
||||
|
||||
collection["clips"] = new_order
|
||||
if not self.socket is None:
|
||||
self.socket.emit('collection_updated', {'collection': collection})
|
||||
self.save_metadata()
|
||||
|
||||
def save_metadata(self):
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -98,3 +98,9 @@ def edit_clip_in_collection():
|
||||
return jsonify({'status': 'success', 'collections': collections})
|
||||
except ValueError as e:
|
||||
return jsonify({'status': 'error', 'message': str(e)}), 400
|
||||
|
||||
|
||||
@metadata_bp.route('/ws/test', methods=['POST'])
|
||||
def test_websocket():
|
||||
MetaDataManager().socket.emit('test_event', {'data': 'Test message from metadata route'})
|
||||
return jsonify({'status': 'success'})
|
||||
Reference in New Issue
Block a user