metadata fixes, redux start. Lifecycle fixes for regions, etc
This commit is contained in:
Binary file not shown.
BIN
audio-service/src/__pycache__/main.cpython-313.pyc
Normal file
BIN
audio-service/src/__pycache__/main.cpython-313.pyc
Normal file
Binary file not shown.
Binary file not shown.
@ -96,16 +96,21 @@ class AudioRecorder:
|
||||
wavfile.write(filename, int(self.sample_rate), audio_data_int16)
|
||||
|
||||
meta = MetaDataManager()
|
||||
|
||||
meta.add_clip_to_collection("Uncategorized",
|
||||
{
|
||||
|
||||
clip_metadata = {
|
||||
"filename": filename,
|
||||
"name": f"Clip {timestamp}",
|
||||
"playbackType":"playStop",
|
||||
"volume": 1.0,
|
||||
})
|
||||
}
|
||||
|
||||
return filename
|
||||
meta.add_clip_to_collection("Uncategorized",
|
||||
{
|
||||
clip_metadata
|
||||
})
|
||||
|
||||
|
||||
return clip_metadata
|
||||
|
||||
def set_buffer_duration(self, duration):
|
||||
"""
|
||||
|
||||
@ -8,14 +8,19 @@ from metadata_manager import MetaDataManager
|
||||
from settings import SettingsManager
|
||||
|
||||
from flask import Flask
|
||||
from flask_cors import CORS
|
||||
|
||||
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
|
||||
import threading
|
||||
|
||||
app = Flask(__name__)
|
||||
CORS(app)
|
||||
# socketio = SocketIO(app, cors_allowed_origins="*")
|
||||
# CORS(socketio)
|
||||
|
||||
def main():
|
||||
# Create argument parser
|
||||
@ -42,6 +47,7 @@ def main():
|
||||
app.register_blueprint(metadata_bp)
|
||||
app.register_blueprint(settings_bp)
|
||||
app.run(host='127.0.0.1', port=args.osc_port, debug=False, use_reloader=True)
|
||||
# socketio.run(app, host='127.0.0.1', port=args.osc_port, debug=False, use_reloader=True)
|
||||
|
||||
|
||||
|
||||
|
||||
20
audio-service/src/metadata.json
Normal file
20
audio-service/src/metadata.json
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"Uncategorized": [
|
||||
{
|
||||
"endTime": 12.489270386266055,
|
||||
"filename": "C:\\Users\\mickl\\Desktop\\cliptrim-ui\\ClipTrimApp\\audio-service\\src\\recordings\\audio_capture_20260214_133540.wav",
|
||||
"name": "Clip 20260214_133540",
|
||||
"playbackType": "playStop",
|
||||
"startTime": 10.622317596566523,
|
||||
"volume": 1
|
||||
},
|
||||
{
|
||||
"endTime": 6.824034334763957,
|
||||
"filename": "C:\\Users\\mickl\\Desktop\\cliptrim-ui\\ClipTrimApp\\audio-service\\src\\recordings\\audio_capture_20260214_133137.wav",
|
||||
"name": "Clip 20260214_133137",
|
||||
"playbackType": "playStop",
|
||||
"startTime": 3.7982832618025753,
|
||||
"volume": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@ -4,6 +4,12 @@ from metadata_manager import MetaDataManager
|
||||
|
||||
metadata_bp = Blueprint('metadata', __name__)
|
||||
|
||||
@metadata_bp.route('/meta', methods=['GET'])
|
||||
def get_allmetadata():
|
||||
meta_manager = MetaDataManager()
|
||||
collections = meta_manager.collections
|
||||
return jsonify({'status': 'success', 'collections': collections})
|
||||
|
||||
@metadata_bp.route('/meta/collections', methods=['GET'])
|
||||
def get_collections():
|
||||
meta_manager = MetaDataManager()
|
||||
@ -16,7 +22,8 @@ def add_collection():
|
||||
collection_name = request.json.get('name')
|
||||
try:
|
||||
meta_manager.create_collection(collection_name)
|
||||
return jsonify({'status': 'success', 'collection': collection_name})
|
||||
collections = meta_manager.collections
|
||||
return jsonify({'status': 'success', 'collections': collections})
|
||||
except ValueError as e:
|
||||
return jsonify({'status': 'error', 'message': str(e)}), 400
|
||||
|
||||
@ -30,14 +37,15 @@ def get_clips_in_collection(name):
|
||||
except ValueError as e:
|
||||
return jsonify({'status': 'error', 'message': str(e)}), 400
|
||||
|
||||
@metadata_bp.route('/meta/collection/clips/reorder', methods=['POST']):
|
||||
@metadata_bp.route('/meta/collection/clips/reorder', methods=['POST'])
|
||||
def reorder_clips_in_collection():
|
||||
meta_manager = MetaDataManager()
|
||||
collection_name = request.json.get('name')
|
||||
new_order = request.json.get('clips')
|
||||
try:
|
||||
meta_manager.reorder_clips_in_collection(collection_name, new_order)
|
||||
return jsonify({'status': 'success', 'clips': new_order})
|
||||
collections = meta_manager.collections
|
||||
return jsonify({'status': 'success', 'collections': collections})
|
||||
except ValueError as e:
|
||||
return jsonify({'status': 'error', 'message': str(e)}), 400
|
||||
|
||||
@ -48,8 +56,8 @@ def add_clip_to_collection():
|
||||
clip_metadata = request.json.get('clip')
|
||||
try:
|
||||
meta_manager.add_clip_to_collection(collection_name, clip_metadata)
|
||||
clips = meta_manager.get_clips_in_collection(collection_name)
|
||||
return jsonify({'status': 'success', 'clips': clips})
|
||||
collections = meta_manager.collections
|
||||
return jsonify({'status': 'success', 'collections': collections})
|
||||
except ValueError as e:
|
||||
return jsonify({'status': 'error', 'message': str(e)}), 400
|
||||
|
||||
@ -70,9 +78,10 @@ def edit_clip_in_collection():
|
||||
meta_manager = MetaDataManager()
|
||||
collection_name = request.json.get('name')
|
||||
clip_metadata = request.json.get('clip')
|
||||
print(f"Received request to edit clip in collection '{collection_name}': {clip_metadata}")
|
||||
try:
|
||||
meta_manager.edit_clip_in_collection(collection_name, clip_metadata)
|
||||
clips = meta_manager.get_clips_in_collection(collection_name)
|
||||
return jsonify({'status': 'success', 'clips': clips})
|
||||
collections = meta_manager.collections
|
||||
return jsonify({'status': 'success', 'collections': collections})
|
||||
except ValueError as e:
|
||||
return jsonify({'status': 'error', 'message': str(e)}), 400
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
|
||||
from flask import Blueprint, request, jsonify
|
||||
from audio_recorder import AudioRecorder
|
||||
import os
|
||||
|
||||
recording_bp = Blueprint('recording', __name__)
|
||||
|
||||
@ -31,4 +32,13 @@ def recording_status():
|
||||
recorder = AudioRecorder()
|
||||
print('HTTP: Checking recording status')
|
||||
status = 'recording' if recorder.is_recording() else 'stopped'
|
||||
return jsonify({'status': status})
|
||||
return jsonify({'status': status})
|
||||
|
||||
@recording_bp.route('/record/delete', methods=['POST'])
|
||||
def recording_delete():
|
||||
filename = request.json.get('filename')
|
||||
try:
|
||||
os.remove(filename)
|
||||
return jsonify({'status': 'success'})
|
||||
except Exception as e:
|
||||
return jsonify({'status': 'error', 'message': str(e)}), 400
|
||||
10
audio-service/src/settings.json
Normal file
10
audio-service/src/settings.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"input_device": {
|
||||
"index": 0,
|
||||
"name": "Microsoft Sound Mapper - Input",
|
||||
"max_input_channels": 2,
|
||||
"default_samplerate": 44100.0
|
||||
},
|
||||
"save_path": "C:\\Users\\mickl\\Desktop\\cliptrim-ui\\ClipTrimApp\\audio-service\\src\\recordings",
|
||||
"recording_length": 15
|
||||
}
|
||||
Reference in New Issue
Block a user