Spaces:
Sleeping
Sleeping
Commit ·
b497894
1
Parent(s): 522244f
Fix: Carico la versione corretta della demo UI
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- README.md +0 -49
- api.py +0 -92
- app.py +51 -0
- batch_processor.py +0 -294
- config.yaml +0 -169
- input_audio/cello_voci.wav +0 -3
- input_audio/cogl.wav +0 -3
- input_audio/harm.wav +0 -3
- input_audio/voce_formale.mp3 +0 -0
- input_audio/voce_me.wav +0 -3
- input_audio/voce_silenzi.wav +0 -3
- processors/__pycache__/audio_normalizer.cpython-313.pyc +0 -0
- processors/__pycache__/batch_validator.cpython-313.pyc +0 -0
- processors/__pycache__/format_converter.cpython-313.pyc +0 -0
- processors/__pycache__/metadata_extractor.cpython-313.pyc +0 -0
- processors/__pycache__/noise_reducer.cpython-313.pyc +0 -0
- processors/audio_normalizer.py +0 -51
- processors/batch_validator.py +0 -129
- processors/format_converter.py +0 -67
- processors/init.py +0 -22
- processors/metadata_extractor.py +0 -95
- processors/noise_reducer.py +0 -49
- reports/__pycache__/batch_report_generator.cpython-313.pyc +0 -0
- reports/__pycache__/processing_stats.cpython-313.pyc +0 -0
- reports/__pycache__/quality_analyzer.cpython-313.pyc +0 -0
- reports/batch_report_generator.py +0 -131
- reports/init.py +0 -18
- reports/processing_stats.py +0 -179
- reports/quality_analyzer.py +0 -174
- requirements.txt +2 -18
- templates/html_template.html +0 -69
- templates/markdown_template.md +0 -38
- test_basic.py +0 -546
- test_complete.py +0 -546
- test_results/audio_files/01_normal_tone.wav +0 -3
- test_results/audio_files/02_noisy_audio.wav +0 -3
- test_results/audio_files/03_clipped_audio.wav +0 -3
- test_results/audio_files/04_quiet_audio.wav +0 -3
- test_results/audio_files/05_complex_audio.wav +0 -3
- test_results/audio_files/06_audio_with_pauses.wav +0 -3
- test_results/processed/converted_01_normal_tone.flac +0 -0
- test_results/processed/converted_02_noisy_audio.ogg +0 -0
- test_results/processed/denoised_01_normal_tone.wav +0 -3
- test_results/processed/denoised_02_noisy_audio.wav +0 -3
- test_results/processed/denoised_03_clipped_audio.wav +0 -3
- test_results/processed/integration_01_normal_tone.wav +0 -3
- test_results/processed/integration_02_noisy_audio.wav +0 -3
- test_results/processed/integration_03_clipped_audio.wav +0 -3
- test_results/processed/integration_04_quiet_audio.wav +0 -3
- test_results/processed/integration_05_complex_audio.wav +0 -3
README.md
DELETED
|
@@ -1,49 +0,0 @@
|
|
| 1 |
-
# Week 2: Batch Audio Processor
|
| 2 |
-
|
| 3 |
-
## Automated Audio File Processing Workflows
|
| 4 |
-
Enterprise-grade batch processing system for large-scale audio analysis.
|
| 5 |
-
|
| 6 |
-
### 🎯 PROJECT OBJECTIVES
|
| 7 |
-
- Develop scalable batch processing architecture
|
| 8 |
-
- Implement automated workflow management
|
| 9 |
-
- Handle multiple audio formats and quality levels
|
| 10 |
-
- Create foundation for enterprise audio systems
|
| 11 |
-
|
| 12 |
-
### 🔧 TECHNICAL FEATURES
|
| 13 |
-
- **Batch Processing**: Process hundreds of audio files automatically
|
| 14 |
-
- **Format Support**: WAV, MP3, FLAC, AAC compatibility
|
| 15 |
-
- **Quality Control**: Automated audio quality assessment
|
| 16 |
-
- **Metadata Extraction**: Comprehensive file analysis
|
| 17 |
-
- **Progress Tracking**: Real-time processing status
|
| 18 |
-
|
| 19 |
-
### 📊 CORE CAPABILITIES
|
| 20 |
-
- **Scalable Architecture**: Handle large file collections efficiently
|
| 21 |
-
- **Error Handling**: Robust processing with failure recovery
|
| 22 |
-
- **Parallel Processing**: Multi-threaded file processing
|
| 23 |
-
- **Report Generation**: Detailed analysis summaries
|
| 24 |
-
|
| 25 |
-
### 🛠️ TECHNOLOGY STACK
|
| 26 |
-
- **Audio Processing**: librosa, soundfile, pydub
|
| 27 |
-
- **Parallel Processing**: multiprocessing, threading
|
| 28 |
-
- **File Management**: pathlib, os integration
|
| 29 |
-
- **Reporting**: pandas, JSON/CSV export
|
| 30 |
-
|
| 31 |
-
### 📁 FILES
|
| 32 |
-
- `batch_processor.py` - Main processing engine
|
| 33 |
-
- `config.yaml` - Configuration settings
|
| 34 |
-
- `processors/` - Individual processing modules
|
| 35 |
-
- `reports/` - Output analysis reports
|
| 36 |
-
|
| 37 |
-
### 🎓 LEARNING OUTCOMES
|
| 38 |
-
- Scalable system architecture design
|
| 39 |
-
- Enterprise error handling patterns
|
| 40 |
-
- File I/O optimization techniques
|
| 41 |
-
- Automated workflow development
|
| 42 |
-
|
| 43 |
-
### 📈 APPLICATIONS
|
| 44 |
-
- Archive digitization projects
|
| 45 |
-
- Quality control for audio collections
|
| 46 |
-
- Automated metadata generation
|
| 47 |
-
- Large-scale audio analysis
|
| 48 |
-
|
| 49 |
-
**Status**: Production-ready batch processing system
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
api.py
DELETED
|
@@ -1,92 +0,0 @@
|
|
| 1 |
-
import yaml
|
| 2 |
-
import zipfile
|
| 3 |
-
import tempfile
|
| 4 |
-
import shutil
|
| 5 |
-
from pathlib import Path
|
| 6 |
-
from fastapi import FastAPI, UploadFile, File, HTTPException
|
| 7 |
-
from typing import List
|
| 8 |
-
|
| 9 |
-
# Importa i moduli che hai creato e testato
|
| 10 |
-
from processors.audio_normalizer import AudioNormalizer
|
| 11 |
-
from processors.noise_reducer import NoiseReducer
|
| 12 |
-
from processors.format_converter import FormatConverter
|
| 13 |
-
from processors.metadata_extractor import MetadataExtractor
|
| 14 |
-
from reports.quality_analyzer import QualityAnalyzer
|
| 15 |
-
from reports.processing_stats import ProcessingStats
|
| 16 |
-
|
| 17 |
-
# --- Configurazione ---
|
| 18 |
-
# Carica la configurazione dal file YAML
|
| 19 |
-
try:
|
| 20 |
-
with open("config.yaml", 'r') as f:
|
| 21 |
-
config = yaml.safe_load(f)
|
| 22 |
-
except FileNotFoundError:
|
| 23 |
-
raise RuntimeError("Errore: config.yaml non trovato. Assicurati che sia nella stessa cartella di api.py")
|
| 24 |
-
|
| 25 |
-
# Inizializza l'applicazione FastAPI
|
| 26 |
-
app = FastAPI(
|
| 27 |
-
title="Week 2 - Batch Processing API",
|
| 28 |
-
description="API per processare batch di file audio usando un sistema modulare.",
|
| 29 |
-
version="2.0.0"
|
| 30 |
-
)
|
| 31 |
-
|
| 32 |
-
# --- Logica Principale dell'API ---
|
| 33 |
-
@app.post("/process-batch/")
|
| 34 |
-
async def process_batch(file: UploadFile = File(...)):
|
| 35 |
-
"""
|
| 36 |
-
Endpoint per processare un batch di file audio caricati come file .zip.
|
| 37 |
-
"""
|
| 38 |
-
if not file.filename.endswith('.zip'):
|
| 39 |
-
raise HTTPException(status_code=400, detail="File non valido. Per favore carica un file .zip.")
|
| 40 |
-
|
| 41 |
-
# Crea una directory di lavoro temporanea e sicura
|
| 42 |
-
with tempfile.TemporaryDirectory() as temp_dir:
|
| 43 |
-
temp_path = Path(temp_dir)
|
| 44 |
-
zip_path = temp_path / file.filename
|
| 45 |
-
input_dir = temp_path / "input"
|
| 46 |
-
output_dir = temp_path / "output"
|
| 47 |
-
|
| 48 |
-
input_dir.mkdir()
|
| 49 |
-
output_dir.mkdir()
|
| 50 |
-
|
| 51 |
-
# 1. Salva ed estrai il file .zip
|
| 52 |
-
try:
|
| 53 |
-
with open(zip_path, "wb") as buffer:
|
| 54 |
-
shutil.copyfileobj(file.file, buffer)
|
| 55 |
-
|
| 56 |
-
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
|
| 57 |
-
zip_ref.extractall(input_dir)
|
| 58 |
-
except Exception as e:
|
| 59 |
-
raise HTTPException(status_code=500, detail=f"Errore nell'estrazione del file zip: {e}")
|
| 60 |
-
|
| 61 |
-
# 2. Esegui il pipeline di processamento
|
| 62 |
-
# Inizializza i moduli necessari
|
| 63 |
-
normalizer = AudioNormalizer()
|
| 64 |
-
noise_reducer = NoiseReducer()
|
| 65 |
-
# ... qui puoi inizializzare altri processori se necessario
|
| 66 |
-
|
| 67 |
-
stats = ProcessingStats()
|
| 68 |
-
|
| 69 |
-
audio_files = list(input_dir.glob("*.*"))
|
| 70 |
-
stats.start_batch("api_processing", len(audio_files))
|
| 71 |
-
|
| 72 |
-
for audio_file in audio_files:
|
| 73 |
-
try:
|
| 74 |
-
# Esempio di pipeline: normalizzazione + riduzione rumore
|
| 75 |
-
normalized_path = output_dir / f"norm_{audio_file.name}"
|
| 76 |
-
normalizer.normalize_audio(str(audio_file), str(normalized_path))
|
| 77 |
-
|
| 78 |
-
denoised_path = output_dir / f"final_{audio_file.name}"
|
| 79 |
-
noise_reducer.reduce_noise(str(normalized_path), str(denoised_path))
|
| 80 |
-
|
| 81 |
-
stats.record_file_processing(str(audio_file), success=True, processing_time=0.1) # Simula tempo
|
| 82 |
-
except Exception as e:
|
| 83 |
-
stats.record_file_processing(str(audio_file), success=False, processing_time=0.1, error=str(e))
|
| 84 |
-
|
| 85 |
-
# 3. Genera e restituisci il report finale
|
| 86 |
-
final_report = stats.finish_batch()
|
| 87 |
-
|
| 88 |
-
return final_report
|
| 89 |
-
|
| 90 |
-
@app.get("/")
|
| 91 |
-
def read_root():
|
| 92 |
-
return {"status": "Batch Processing API is running. Usa l'endpoint /process-batch/ per caricare un file .zip."}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.py
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import requests
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
# --- INSERISCI L'URL DELLA TUA API RENDER ---
|
| 6 |
+
API_URL = "https://audio-batch-api.onrender.com/process-batch/"
|
| 7 |
+
# -------------------------------------------
|
| 8 |
+
|
| 9 |
+
def process_batch_via_api(zip_file):
|
| 10 |
+
if zip_file is None:
|
| 11 |
+
return "Per favore, carica un file .zip per iniziare.", None
|
| 12 |
+
try:
|
| 13 |
+
with open(zip_file.name, 'rb') as f:
|
| 14 |
+
files = {'file': (os.path.basename(zip_file.name), f, 'application/zip')}
|
| 15 |
+
yield "🚀 Invio del batch all'API... L'elaborazione potrebbe richiedere qualche minuto.", None
|
| 16 |
+
response = requests.post(API_URL, files=files, timeout=300)
|
| 17 |
+
response.raise_for_status()
|
| 18 |
+
data = response.json()
|
| 19 |
+
summary = data.get('summary', {})
|
| 20 |
+
formatted_report = f"""
|
| 21 |
+
## ✅ Batch Processato con Successo!
|
| 22 |
+
| Metrica | Valore |
|
| 23 |
+
|---|---|
|
| 24 |
+
| **File Totali** | {summary.get('total_files', 0)} |
|
| 25 |
+
| **Processati con Successo** | {summary.get('successful', 0)} |
|
| 26 |
+
| **Falliti** | {summary.get('failed', 0)} |
|
| 27 |
+
| **Tasso di Successo** | {summary.get('success_rate', 0):.2f}% |
|
| 28 |
+
| **Tempo Totale** | {summary.get('total_time', 0):.2f} secondi |
|
| 29 |
+
| **Throughput** | {summary.get('throughput', 0):.2f} file/sec |
|
| 30 |
+
"""
|
| 31 |
+
yield formatted_report, data
|
| 32 |
+
except requests.exceptions.Timeout:
|
| 33 |
+
yield "❌ **Errore**: Timeout. Il batch potrebbe essere troppo grande.", None
|
| 34 |
+
except requests.exceptions.RequestException as e:
|
| 35 |
+
yield f"❌ **Errore di Connessione**: {e}", None
|
| 36 |
+
except Exception as e:
|
| 37 |
+
yield f"❌ **Errore Inaspettato**: {e}", None
|
| 38 |
+
|
| 39 |
+
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 40 |
+
gr.Markdown("# 🎵 Demo: Batch Audio Processor (Week 2)")
|
| 41 |
+
gr.Markdown("Carica un file `.zip` con più file audio. Il sistema li processerà tramite un'API sicura.")
|
| 42 |
+
zip_uploader = gr.File(label="Carica il tuo Batch (.zip)", file_types=['.zip'])
|
| 43 |
+
process_button = gr.Button("🚀 Avvia Processamento", variant="primary")
|
| 44 |
+
with gr.Tabs():
|
| 45 |
+
with gr.TabItem("📊 Report Riassuntivo"):
|
| 46 |
+
report_output = gr.Markdown()
|
| 47 |
+
with gr.TabItem("📄 Dati JSON Completi"):
|
| 48 |
+
json_output = gr.JSON(label="Risposta completa dall'API")
|
| 49 |
+
process_button.click(fn=process_batch_via_api, inputs=zip_uploader, outputs=[report_output, json_output])
|
| 50 |
+
|
| 51 |
+
demo.launch()
|
batch_processor.py
DELETED
|
@@ -1,294 +0,0 @@
|
|
| 1 |
-
"""
|
| 2 |
-
Audio AI Projects - Advanced Audio Processing System
|
| 3 |
-
Copyright (c) 2025 Antonino Mainenti (ninuxi)
|
| 4 |
-
Licensed under MIT License - see LICENSE file
|
| 5 |
-
GitHub: https://github.com/ninuxi/audio-ai-projects
|
| 6 |
-
"""
|
| 7 |
-
import librosa
|
| 8 |
-
import pandas as pd
|
| 9 |
-
import numpy as np
|
| 10 |
-
import os
|
| 11 |
-
import glob
|
| 12 |
-
from pathlib import Path
|
| 13 |
-
import matplotlib.pyplot as plt
|
| 14 |
-
import seaborn as sns
|
| 15 |
-
|
| 16 |
-
class BatchAudioProcessor:
|
| 17 |
-
"""
|
| 18 |
-
Week 2 Project: Processatore batch per analisi audio multiple
|
| 19 |
-
Obiettivo: Creare dataset da multipli file audio per ML
|
| 20 |
-
"""
|
| 21 |
-
|
| 22 |
-
def __init__(self, audio_folder):
|
| 23 |
-
"""Inizializza processatore batch"""
|
| 24 |
-
self.audio_folder = audio_folder
|
| 25 |
-
self.audio_files = []
|
| 26 |
-
self.features_data = []
|
| 27 |
-
self.dataset = None
|
| 28 |
-
|
| 29 |
-
# Trova tutti i file audio nella cartella
|
| 30 |
-
self.find_audio_files()
|
| 31 |
-
|
| 32 |
-
print(f"📁 Cartella audio: {audio_folder}")
|
| 33 |
-
print(f"🎵 File audio trovati: {len(self.audio_files)}")
|
| 34 |
-
|
| 35 |
-
def find_audio_files(self):
|
| 36 |
-
"""Trova tutti i file audio nella cartella"""
|
| 37 |
-
extensions = ['*.wav', '*.mp3', '*.flac', '*.m4a', '*.aiff']
|
| 38 |
-
|
| 39 |
-
for ext in extensions:
|
| 40 |
-
pattern = os.path.join(self.audio_folder, ext)
|
| 41 |
-
self.audio_files.extend(glob.glob(pattern))
|
| 42 |
-
|
| 43 |
-
# Ordina i file
|
| 44 |
-
self.audio_files.sort()
|
| 45 |
-
|
| 46 |
-
print("\n📋 FILE TROVATI:")
|
| 47 |
-
for i, file in enumerate(self.audio_files, 1):
|
| 48 |
-
filename = os.path.basename(file)
|
| 49 |
-
print(f"{i:2d}. {filename}")
|
| 50 |
-
|
| 51 |
-
def extract_features_single(self, audio_path):
|
| 52 |
-
"""Estrae features da un singolo file audio"""
|
| 53 |
-
try:
|
| 54 |
-
# Carica audio
|
| 55 |
-
y, sr = librosa.load(audio_path, sr=None)
|
| 56 |
-
duration = len(y) / sr
|
| 57 |
-
|
| 58 |
-
# Features base
|
| 59 |
-
features = {
|
| 60 |
-
'filename': os.path.basename(audio_path),
|
| 61 |
-
'duration': duration,
|
| 62 |
-
'sample_rate': sr,
|
| 63 |
-
'samples': len(y)
|
| 64 |
-
}
|
| 65 |
-
|
| 66 |
-
# MFCC (usa solo la media dei coefficienti)
|
| 67 |
-
mfccs = librosa.feature.mfcc(y=y, sr=sr, n_mfcc=13)
|
| 68 |
-
for i in range(13):
|
| 69 |
-
features[f'mfcc_{i}_mean'] = np.mean(mfccs[i])
|
| 70 |
-
features[f'mfcc_{i}_std'] = np.std(mfccs[i])
|
| 71 |
-
|
| 72 |
-
# Chroma features
|
| 73 |
-
chroma = librosa.feature.chroma_stft(y=y, sr=sr)
|
| 74 |
-
for i in range(12):
|
| 75 |
-
features[f'chroma_{i}_mean'] = np.mean(chroma[i])
|
| 76 |
-
|
| 77 |
-
# Spectral features
|
| 78 |
-
spectral_centroid = librosa.feature.spectral_centroid(y=y, sr=sr)
|
| 79 |
-
features['spectral_centroid_mean'] = np.mean(spectral_centroid)
|
| 80 |
-
features['spectral_centroid_std'] = np.std(spectral_centroid)
|
| 81 |
-
|
| 82 |
-
spectral_rolloff = librosa.feature.spectral_rolloff(y=y, sr=sr)
|
| 83 |
-
features['spectral_rolloff_mean'] = np.mean(spectral_rolloff)
|
| 84 |
-
features['spectral_rolloff_std'] = np.std(spectral_rolloff)
|
| 85 |
-
|
| 86 |
-
spectral_bandwidth = librosa.feature.spectral_bandwidth(y=y, sr=sr)
|
| 87 |
-
features['spectral_bandwidth_mean'] = np.mean(spectral_bandwidth)
|
| 88 |
-
features['spectral_bandwidth_std'] = np.std(spectral_bandwidth)
|
| 89 |
-
|
| 90 |
-
# Zero crossing rate
|
| 91 |
-
zcr = librosa.feature.zero_crossing_rate(y)
|
| 92 |
-
features['zcr_mean'] = np.mean(zcr)
|
| 93 |
-
features['zcr_std'] = np.std(zcr)
|
| 94 |
-
|
| 95 |
-
# Tempo e ritmo
|
| 96 |
-
tempo, beats = librosa.beat.beat_track(y=y, sr=sr)
|
| 97 |
-
features['tempo'] = float(tempo)
|
| 98 |
-
features['beats_count'] = len(beats)
|
| 99 |
-
|
| 100 |
-
# Onsets
|
| 101 |
-
onsets = librosa.onset.onset_detect(y=y, sr=sr)
|
| 102 |
-
features['onsets_count'] = len(onsets)
|
| 103 |
-
|
| 104 |
-
# RMS energy
|
| 105 |
-
rms = librosa.feature.rms(y=y)
|
| 106 |
-
features['rms_mean'] = np.mean(rms)
|
| 107 |
-
features['rms_std'] = np.std(rms)
|
| 108 |
-
|
| 109 |
-
# Spectral contrast
|
| 110 |
-
spectral_contrast = librosa.feature.spectral_contrast(y=y, sr=sr)
|
| 111 |
-
features['spectral_contrast_mean'] = np.mean(spectral_contrast)
|
| 112 |
-
features['spectral_contrast_std'] = np.std(spectral_contrast)
|
| 113 |
-
|
| 114 |
-
# Classificazione automatica semplice
|
| 115 |
-
if features['zcr_mean'] > 0.1:
|
| 116 |
-
features['auto_classification'] = 'voice'
|
| 117 |
-
elif features['spectral_centroid_mean'] > 3000:
|
| 118 |
-
features['auto_classification'] = 'music_bright'
|
| 119 |
-
elif features['spectral_centroid_mean'] < 1000:
|
| 120 |
-
features['auto_classification'] = 'music_dark'
|
| 121 |
-
else:
|
| 122 |
-
features['auto_classification'] = 'music_mixed'
|
| 123 |
-
|
| 124 |
-
return features
|
| 125 |
-
|
| 126 |
-
except Exception as e:
|
| 127 |
-
print(f"❌ Errore processando {audio_path}: {e}")
|
| 128 |
-
return None
|
| 129 |
-
|
| 130 |
-
def process_all_files(self):
|
| 131 |
-
"""Processa tutti i file audio"""
|
| 132 |
-
print("\n🔄 PROCESSAMENTO BATCH INIZIATO...")
|
| 133 |
-
print("=" * 50)
|
| 134 |
-
|
| 135 |
-
self.features_data = []
|
| 136 |
-
|
| 137 |
-
for i, audio_file in enumerate(self.audio_files, 1):
|
| 138 |
-
filename = os.path.basename(audio_file)
|
| 139 |
-
print(f"\n📊 Processando {i}/{len(self.audio_files)}: {filename}")
|
| 140 |
-
|
| 141 |
-
features = self.extract_features_single(audio_file)
|
| 142 |
-
if features:
|
| 143 |
-
self.features_data.append(features)
|
| 144 |
-
print(f"✅ Features estratte: {len(features)} caratteristiche")
|
| 145 |
-
else:
|
| 146 |
-
print(f"❌ Fallito: {filename}")
|
| 147 |
-
|
| 148 |
-
# Crea DataFrame
|
| 149 |
-
self.dataset = pd.DataFrame(self.features_data)
|
| 150 |
-
|
| 151 |
-
print(f"\n🎯 PROCESSAMENTO COMPLETATO!")
|
| 152 |
-
print(f"📊 Dataset creato: {len(self.dataset)} file, {len(self.dataset.columns)} features")
|
| 153 |
-
|
| 154 |
-
return self.dataset
|
| 155 |
-
|
| 156 |
-
def analyze_dataset(self):
|
| 157 |
-
"""Analizza il dataset creato"""
|
| 158 |
-
if self.dataset is None:
|
| 159 |
-
print("❌ Nessun dataset disponibile. Esegui prima process_all_files()")
|
| 160 |
-
return
|
| 161 |
-
|
| 162 |
-
print("\n📈 ANALISI DATASET")
|
| 163 |
-
print("=" * 40)
|
| 164 |
-
|
| 165 |
-
# Statistiche base
|
| 166 |
-
print(f"📊 Numero file: {len(self.dataset)}")
|
| 167 |
-
print(f"🔢 Numero features: {len(self.dataset.columns)}")
|
| 168 |
-
print(f"📁 Tipi di file: {self.dataset['filename'].apply(lambda x: x.split('.')[-1]).value_counts().to_dict()}")
|
| 169 |
-
|
| 170 |
-
# Classificazione automatica
|
| 171 |
-
print(f"\n🤖 CLASSIFICAZIONE AUTOMATICA:")
|
| 172 |
-
classification_counts = self.dataset['auto_classification'].value_counts()
|
| 173 |
-
for classification, count in classification_counts.items():
|
| 174 |
-
print(f" {classification}: {count} file")
|
| 175 |
-
|
| 176 |
-
# Statistiche durata
|
| 177 |
-
print(f"\n⏱️ DURATA:")
|
| 178 |
-
print(f" Media: {self.dataset['duration'].mean():.2f} secondi")
|
| 179 |
-
print(f" Min: {self.dataset['duration'].min():.2f} secondi")
|
| 180 |
-
print(f" Max: {self.dataset['duration'].max():.2f} secondi")
|
| 181 |
-
|
| 182 |
-
# Statistiche tempo
|
| 183 |
-
print(f"\n🎵 TEMPO:")
|
| 184 |
-
print(f" Media: {self.dataset['tempo'].mean():.1f} BPM")
|
| 185 |
-
print(f" Min: {self.dataset['tempo'].min():.1f} BPM")
|
| 186 |
-
print(f" Max: {self.dataset['tempo'].max():.1f} BPM")
|
| 187 |
-
|
| 188 |
-
# Top 5 file per diverse caratteristiche
|
| 189 |
-
print(f"\n🔝 FILE PIÙ ENERGETICI (RMS):")
|
| 190 |
-
top_energy = self.dataset.nlargest(3, 'rms_mean')[['filename', 'rms_mean', 'auto_classification']]
|
| 191 |
-
for _, row in top_energy.iterrows():
|
| 192 |
-
print(f" {row['filename']}: {row['rms_mean']:.3f} ({row['auto_classification']})")
|
| 193 |
-
|
| 194 |
-
print(f"\n🎼 FILE PIÙ VELOCI (Tempo):")
|
| 195 |
-
top_tempo = self.dataset.nlargest(3, 'tempo')[['filename', 'tempo', 'auto_classification']]
|
| 196 |
-
for _, row in top_tempo.iterrows():
|
| 197 |
-
print(f" {row['filename']}: {row['tempo']:.1f} BPM ({row['auto_classification']})")
|
| 198 |
-
|
| 199 |
-
def visualize_dataset(self):
|
| 200 |
-
"""Crea visualizzazioni del dataset"""
|
| 201 |
-
if self.dataset is None:
|
| 202 |
-
print("❌ Nessun dataset disponibile. Esegui prima process_all_files()")
|
| 203 |
-
return
|
| 204 |
-
|
| 205 |
-
# Setup matplotlib
|
| 206 |
-
plt.style.use('default')
|
| 207 |
-
|
| 208 |
-
# Figura con subplots
|
| 209 |
-
fig, axes = plt.subplots(2, 2, figsize=(15, 12))
|
| 210 |
-
|
| 211 |
-
# 1. Distribuzione durata
|
| 212 |
-
axes[0,0].hist(self.dataset['duration'], bins=10, alpha=0.7, color='skyblue')
|
| 213 |
-
axes[0,0].set_title('Distribuzione Durata File')
|
| 214 |
-
axes[0,0].set_xlabel('Durata (secondi)')
|
| 215 |
-
axes[0,0].set_ylabel('Numero di file')
|
| 216 |
-
|
| 217 |
-
# 2. Distribuzione tempo
|
| 218 |
-
axes[0,1].hist(self.dataset['tempo'], bins=10, alpha=0.7, color='lightgreen')
|
| 219 |
-
axes[0,1].set_title('Distribuzione Tempo (BPM)')
|
| 220 |
-
axes[0,1].set_xlabel('Tempo (BPM)')
|
| 221 |
-
axes[0,1].set_ylabel('Numero di file')
|
| 222 |
-
|
| 223 |
-
# 3. Classificazione automatica
|
| 224 |
-
classification_counts = self.dataset['auto_classification'].value_counts()
|
| 225 |
-
axes[1,0].pie(classification_counts.values, labels=classification_counts.index, autopct='%1.1f%%')
|
| 226 |
-
axes[1,0].set_title('Classificazione Automatica')
|
| 227 |
-
|
| 228 |
-
# 4. Scatter plot energia vs tempo
|
| 229 |
-
scatter = axes[1,1].scatter(self.dataset['tempo'], self.dataset['rms_mean'],
|
| 230 |
-
c=self.dataset['spectral_centroid_mean'],
|
| 231 |
-
cmap='viridis', alpha=0.7)
|
| 232 |
-
axes[1,1].set_xlabel('Tempo (BPM)')
|
| 233 |
-
axes[1,1].set_ylabel('Energia RMS')
|
| 234 |
-
axes[1,1].set_title('Energia vs Tempo (colore = Centroide Spettrale)')
|
| 235 |
-
plt.colorbar(scatter, ax=axes[1,1])
|
| 236 |
-
|
| 237 |
-
plt.tight_layout()
|
| 238 |
-
plt.show()
|
| 239 |
-
|
| 240 |
-
def save_dataset(self, output_path='audio_dataset.csv'):
|
| 241 |
-
"""Salva il dataset in CSV"""
|
| 242 |
-
if self.dataset is None:
|
| 243 |
-
print("❌ Nessun dataset disponibile. Esegui prima process_all_files()")
|
| 244 |
-
return
|
| 245 |
-
|
| 246 |
-
self.dataset.to_csv(output_path, index=False)
|
| 247 |
-
print(f"💾 Dataset salvato in: {output_path}")
|
| 248 |
-
print(f"📊 {len(self.dataset)} file, {len(self.dataset.columns)} features")
|
| 249 |
-
|
| 250 |
-
def get_summary(self):
|
| 251 |
-
"""Riassunto del processamento"""
|
| 252 |
-
if self.dataset is None:
|
| 253 |
-
print("❌ Nessun dataset disponibile. Esegui prima process_all_files()")
|
| 254 |
-
return
|
| 255 |
-
|
| 256 |
-
print("\n🎯 RIASSUNTO PROCESSAMENTO")
|
| 257 |
-
print("=" * 40)
|
| 258 |
-
print(f"📁 Cartella processata: {self.audio_folder}")
|
| 259 |
-
print(f"🎵 File processati: {len(self.dataset)}")
|
| 260 |
-
print(f"🔢 Features estratte: {len(self.dataset.columns)}")
|
| 261 |
-
print(f"📊 Dataset pronto per ML: ✅")
|
| 262 |
-
|
| 263 |
-
return self.dataset
|
| 264 |
-
|
| 265 |
-
# Esempio di utilizzo
|
| 266 |
-
if __name__ == "__main__":
|
| 267 |
-
# IMPOSTA LA TUA CARTELLA AUDIO
|
| 268 |
-
audio_folder = "data" # Cambia con la tua cartella
|
| 269 |
-
|
| 270 |
-
try:
|
| 271 |
-
# Crea processatore batch
|
| 272 |
-
processor = BatchAudioProcessor(audio_folder)
|
| 273 |
-
|
| 274 |
-
# Processa tutti i file
|
| 275 |
-
dataset = processor.process_all_files()
|
| 276 |
-
|
| 277 |
-
# Analizza risultati
|
| 278 |
-
processor.analyze_dataset()
|
| 279 |
-
|
| 280 |
-
# Visualizza
|
| 281 |
-
processor.visualize_dataset()
|
| 282 |
-
|
| 283 |
-
# Salva dataset
|
| 284 |
-
processor.save_dataset('audio_features_dataset.csv')
|
| 285 |
-
|
| 286 |
-
# Riassunto
|
| 287 |
-
processor.get_summary()
|
| 288 |
-
|
| 289 |
-
print("\n🎉 BATCH PROCESSING COMPLETATO!")
|
| 290 |
-
print("🚀 Dataset pronto per Machine Learning!")
|
| 291 |
-
|
| 292 |
-
except Exception as e:
|
| 293 |
-
print(f"❌ Errore: {e}")
|
| 294 |
-
print("Controlla che la cartella audio esista e contenga file audio validi")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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|
|
| 1 |
-
# Week 2: Batch Audio Processor - Configuration Settings
|
| 2 |
-
# =====================================================
|
| 3 |
-
|
| 4 |
-
# Audio Processing Settings
|
| 5 |
-
audio:
|
| 6 |
-
sample_rate: 22050 # Target sample rate for analysis
|
| 7 |
-
supported_formats: # Supported audio file formats
|
| 8 |
-
- ".wav"
|
| 9 |
-
- ".mp3"
|
| 10 |
-
- ".flac"
|
| 11 |
-
- ".aiff"
|
| 12 |
-
- ".m4a"
|
| 13 |
-
max_duration: 300 # Maximum duration in seconds (5 minutes)
|
| 14 |
-
normalize_audio: true # Normalize audio levels
|
| 15 |
-
|
| 16 |
-
# Feature Extraction Configuration
|
| 17 |
-
features:
|
| 18 |
-
# MFCC Settings
|
| 19 |
-
mfcc:
|
| 20 |
-
n_mfcc: 13 # Number of MFCC coefficients
|
| 21 |
-
n_fft: 2048 # FFT window size
|
| 22 |
-
hop_length: 512 # Hop length for analysis
|
| 23 |
-
|
| 24 |
-
# Spectral Features
|
| 25 |
-
spectral:
|
| 26 |
-
n_fft: 2048
|
| 27 |
-
hop_length: 512
|
| 28 |
-
|
| 29 |
-
# Chroma Features
|
| 30 |
-
chroma:
|
| 31 |
-
n_chroma: 12
|
| 32 |
-
|
| 33 |
-
# Rhythm Features
|
| 34 |
-
rhythm:
|
| 35 |
-
tempo_estimation: true
|
| 36 |
-
beat_tracking: true
|
| 37 |
-
onset_detection: true
|
| 38 |
-
|
| 39 |
-
# Batch Processing Settings
|
| 40 |
-
batch:
|
| 41 |
-
max_workers: 4 # Number of parallel processing threads
|
| 42 |
-
chunk_size: 10 # Number of files per processing chunk
|
| 43 |
-
memory_limit_mb: 1024 # Memory limit per worker
|
| 44 |
-
timeout_seconds: 60 # Timeout for single file processing
|
| 45 |
-
|
| 46 |
-
# Output Configuration
|
| 47 |
-
output:
|
| 48 |
-
# Dataset Export
|
| 49 |
-
dataset:
|
| 50 |
-
format: "csv" # csv, json, pickle
|
| 51 |
-
include_metadata: true
|
| 52 |
-
normalize_features: true
|
| 53 |
-
|
| 54 |
-
# File Organization
|
| 55 |
-
files:
|
| 56 |
-
create_backups: true
|
| 57 |
-
organize_by_date: false
|
| 58 |
-
organize_by_genre: true
|
| 59 |
-
|
| 60 |
-
# Visualization
|
| 61 |
-
visualization:
|
| 62 |
-
create_plots: true
|
| 63 |
-
plot_format: "png" # png, pdf, svg
|
| 64 |
-
plot_dpi: 150
|
| 65 |
-
|
| 66 |
-
# Classification Settings
|
| 67 |
-
classification:
|
| 68 |
-
# Content Type Detection
|
| 69 |
-
content_detection:
|
| 70 |
-
enable: true
|
| 71 |
-
confidence_threshold: 0.7
|
| 72 |
-
|
| 73 |
-
# Genre Classification
|
| 74 |
-
genre_classification:
|
| 75 |
-
enable: true
|
| 76 |
-
categories:
|
| 77 |
-
- "classical"
|
| 78 |
-
- "jazz"
|
| 79 |
-
- "pop"
|
| 80 |
-
- "rock"
|
| 81 |
-
- "electronic"
|
| 82 |
-
- "folk"
|
| 83 |
-
- "speech"
|
| 84 |
-
- "ambient"
|
| 85 |
-
|
| 86 |
-
# Quality Control
|
| 87 |
-
quality:
|
| 88 |
-
# Audio Quality Checks
|
| 89 |
-
audio_quality:
|
| 90 |
-
min_duration: 1.0 # Minimum duration in seconds
|
| 91 |
-
max_silence: 0.8 # Maximum silence ratio (80%)
|
| 92 |
-
min_snr_db: 10 # Minimum signal-to-noise ratio
|
| 93 |
-
|
| 94 |
-
# Processing Quality
|
| 95 |
-
processing:
|
| 96 |
-
retry_failed: true
|
| 97 |
-
max_retries: 3
|
| 98 |
-
log_level: "INFO" # DEBUG, INFO, WARNING, ERROR
|
| 99 |
-
|
| 100 |
-
# Machine Learning Pipeline
|
| 101 |
-
ml_pipeline:
|
| 102 |
-
# Feature Preprocessing
|
| 103 |
-
preprocessing:
|
| 104 |
-
scale_features: true
|
| 105 |
-
remove_outliers: true
|
| 106 |
-
feature_selection: true
|
| 107 |
-
|
| 108 |
-
# Model Training
|
| 109 |
-
training:
|
| 110 |
-
test_size: 0.2 # Train/test split ratio
|
| 111 |
-
random_state: 42
|
| 112 |
-
cross_validation: 5 # K-fold CV
|
| 113 |
-
|
| 114 |
-
# Reporting Configuration
|
| 115 |
-
reporting:
|
| 116 |
-
# Analysis Reports
|
| 117 |
-
generate_reports: true
|
| 118 |
-
report_format: "html" # html, pdf, markdown
|
| 119 |
-
|
| 120 |
-
# Statistics
|
| 121 |
-
include_statistics: true
|
| 122 |
-
create_visualizations: true
|
| 123 |
-
|
| 124 |
-
# Performance Metrics
|
| 125 |
-
performance_metrics:
|
| 126 |
-
processing_speed: true
|
| 127 |
-
memory_usage: true
|
| 128 |
-
accuracy_metrics: true
|
| 129 |
-
|
| 130 |
-
# Advanced Settings
|
| 131 |
-
advanced:
|
| 132 |
-
# Caching
|
| 133 |
-
enable_caching: true
|
| 134 |
-
cache_location: "./cache"
|
| 135 |
-
|
| 136 |
-
# Debugging
|
| 137 |
-
debug_mode: false
|
| 138 |
-
save_intermediate: false
|
| 139 |
-
|
| 140 |
-
# Integration
|
| 141 |
-
database:
|
| 142 |
-
enable: false
|
| 143 |
-
connection_string: ""
|
| 144 |
-
|
| 145 |
-
# Cloud Storage
|
| 146 |
-
cloud_storage:
|
| 147 |
-
enable: false
|
| 148 |
-
provider: "aws" # aws, gcp, azure
|
| 149 |
-
bucket_name: ""
|
| 150 |
-
|
| 151 |
-
# Professional Settings for Enterprise Use
|
| 152 |
-
enterprise:
|
| 153 |
-
# Resource Management
|
| 154 |
-
resource_limits:
|
| 155 |
-
max_cpu_percent: 80
|
| 156 |
-
max_memory_percent: 70
|
| 157 |
-
max_disk_usage_gb: 10
|
| 158 |
-
|
| 159 |
-
# Monitoring
|
| 160 |
-
monitoring:
|
| 161 |
-
enable_metrics: true
|
| 162 |
-
metrics_interval: 60 # seconds
|
| 163 |
-
health_checks: true
|
| 164 |
-
|
| 165 |
-
# Security
|
| 166 |
-
security:
|
| 167 |
-
encrypt_outputs: false
|
| 168 |
-
secure_temp_files: true
|
| 169 |
-
audit_log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input_audio/cello_voci.wav
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:c0516dafdc31b85b58130b7ab07320feb56af0310000250be3d5838d47d90ef2
|
| 3 |
-
size 5954190
|
|
|
|
|
|
|
|
|
|
|
|
input_audio/cogl.wav
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:ad9598a1ee56555407826153e0cffc029018cba304a19bb93650a89b917333a6
|
| 3 |
-
size 11332908
|
|
|
|
|
|
|
|
|
|
|
|
input_audio/harm.wav
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:c6c22ab5dd7ad14aff690f76635b41d60538e7d8b9e648be442600cb6266a7ee
|
| 3 |
-
size 15876690
|
|
|
|
|
|
|
|
|
|
|
|
input_audio/voce_formale.mp3
DELETED
|
Binary file (64.8 kB)
|
|
|
input_audio/voce_me.wav
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:623a04933137a0531d1a9ba97c558bd83a9b3ae6f52f3511af2e32097492b940
|
| 3 |
-
size 418604
|
|
|
|
|
|
|
|
|
|
|
|
input_audio/voce_silenzi.wav
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:401073f46db6b39ed1322c178dbdb0f7d61b2630880e9cf0c2cb80a3b92aaf5a
|
| 3 |
-
size 997096
|
|
|
|
|
|
|
|
|
|
|
|
processors/__pycache__/audio_normalizer.cpython-313.pyc
DELETED
|
Binary file (2.44 kB)
|
|
|
processors/__pycache__/batch_validator.cpython-313.pyc
DELETED
|
Binary file (5.33 kB)
|
|
|
processors/__pycache__/format_converter.cpython-313.pyc
DELETED
|
Binary file (3.1 kB)
|
|
|
processors/__pycache__/metadata_extractor.cpython-313.pyc
DELETED
|
Binary file (4.72 kB)
|
|
|
processors/__pycache__/noise_reducer.cpython-313.pyc
DELETED
|
Binary file (2.08 kB)
|
|
|
processors/audio_normalizer.py
DELETED
|
@@ -1,51 +0,0 @@
|
|
| 1 |
-
"""
|
| 2 |
-
Audio AI Projects - Advanced Audio Processing System
|
| 3 |
-
Copyright (c) 2025 Antonino Mainenti (ninuxi)
|
| 4 |
-
Licensed under MIT License - see LICENSE file
|
| 5 |
-
GitHub: https://github.com/ninuxi/audio-ai-projects
|
| 6 |
-
"""
|
| 7 |
-
import librosa
|
| 8 |
-
import soundfile as sf
|
| 9 |
-
import numpy as np
|
| 10 |
-
from typing import Tuple, Optional
|
| 11 |
-
|
| 12 |
-
class AudioNormalizer:
|
| 13 |
-
"""Normalize audio levels for consistent processing"""
|
| 14 |
-
|
| 15 |
-
def __init__(self, target_lufs: float = -23.0):
|
| 16 |
-
self.target_lufs = target_lufs
|
| 17 |
-
|
| 18 |
-
def normalize_audio(self, audio_path: str, output_path: str) -> bool:
|
| 19 |
-
"""
|
| 20 |
-
Normalize audio to target LUFS level
|
| 21 |
-
|
| 22 |
-
Args:
|
| 23 |
-
audio_path: Input audio file path
|
| 24 |
-
output_path: Output normalized audio path
|
| 25 |
-
|
| 26 |
-
Returns:
|
| 27 |
-
bool: Success status
|
| 28 |
-
"""
|
| 29 |
-
try:
|
| 30 |
-
# Load audio
|
| 31 |
-
audio, sr = librosa.load(audio_path, sr=None)
|
| 32 |
-
|
| 33 |
-
# Calculate RMS and normalize
|
| 34 |
-
rms = np.sqrt(np.mean(audio**2))
|
| 35 |
-
if rms > 0:
|
| 36 |
-
target_rms = 10**(self.target_lufs/20)
|
| 37 |
-
normalized_audio = audio * (target_rms / rms)
|
| 38 |
-
else:
|
| 39 |
-
normalized_audio = audio
|
| 40 |
-
|
| 41 |
-
# Prevent clipping
|
| 42 |
-
if np.max(np.abs(normalized_audio)) > 1.0:
|
| 43 |
-
normalized_audio = normalized_audio / np.max(np.abs(normalized_audio))
|
| 44 |
-
|
| 45 |
-
# Save normalized audio
|
| 46 |
-
sf.write(output_path, normalized_audio, sr)
|
| 47 |
-
return True
|
| 48 |
-
|
| 49 |
-
except Exception as e:
|
| 50 |
-
print(f"Normalization error for {audio_path}: {e}")
|
| 51 |
-
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
processors/batch_validator.py
DELETED
|
@@ -1,129 +0,0 @@
|
|
| 1 |
-
"""
|
| 2 |
-
Audio AI Projects - Advanced Audio Processing System
|
| 3 |
-
Copyright (c) 2025 Antonino Mainenti (ninuxi)
|
| 4 |
-
Licensed under MIT License - see LICENSE file
|
| 5 |
-
GitHub: https://github.com/ninuxi/audio-ai-projects
|
| 6 |
-
"""
|
| 7 |
-
import librosa
|
| 8 |
-
from pathlib import Path
|
| 9 |
-
import json
|
| 10 |
-
from typing import Dict, List, Any
|
| 11 |
-
import hashlib
|
| 12 |
-
|
| 13 |
-
class BatchValidator:
|
| 14 |
-
"""Validate audio files and batch processing results"""
|
| 15 |
-
|
| 16 |
-
def __init__(self):
|
| 17 |
-
self.min_duration = 0.1 # Minimum 0.1 seconds
|
| 18 |
-
self.max_duration = 3600 # Maximum 1 hour
|
| 19 |
-
self.supported_formats = ['.wav', '.mp3', '.flac', '.ogg', '.m4a']
|
| 20 |
-
|
| 21 |
-
def validate_audio_file(self, audio_path: str) -> Dict[str, Any]:
|
| 22 |
-
"""
|
| 23 |
-
Validate individual audio file
|
| 24 |
-
|
| 25 |
-
Args:
|
| 26 |
-
audio_path: Path to audio file
|
| 27 |
-
|
| 28 |
-
Returns:
|
| 29 |
-
Dict with validation results
|
| 30 |
-
"""
|
| 31 |
-
validation = {
|
| 32 |
-
'file_path': audio_path,
|
| 33 |
-
'is_valid': False,
|
| 34 |
-
'errors': [],
|
| 35 |
-
'warnings': [],
|
| 36 |
-
'file_hash': None
|
| 37 |
-
}
|
| 38 |
-
|
| 39 |
-
try:
|
| 40 |
-
file_path = Path(audio_path)
|
| 41 |
-
|
| 42 |
-
# Check if file exists
|
| 43 |
-
if not file_path.exists():
|
| 44 |
-
validation['errors'].append('File does not exist')
|
| 45 |
-
return validation
|
| 46 |
-
|
| 47 |
-
# Check file extension
|
| 48 |
-
if file_path.suffix.lower() not in self.supported_formats:
|
| 49 |
-
validation['errors'].append(f'Unsupported format: {file_path.suffix}')
|
| 50 |
-
|
| 51 |
-
# Try to load audio
|
| 52 |
-
try:
|
| 53 |
-
audio, sr = librosa.load(audio_path, sr=None)
|
| 54 |
-
duration = len(audio) / sr
|
| 55 |
-
|
| 56 |
-
# Duration validation
|
| 57 |
-
if duration < self.min_duration:
|
| 58 |
-
validation['errors'].append(f'Duration too short: {duration:.2f}s')
|
| 59 |
-
elif duration > self.max_duration:
|
| 60 |
-
validation['warnings'].append(f'Duration very long: {duration:.2f}s')
|
| 61 |
-
|
| 62 |
-
# Audio quality checks
|
| 63 |
-
if len(audio) == 0:
|
| 64 |
-
validation['errors'].append('Empty audio data')
|
| 65 |
-
|
| 66 |
-
# Calculate file hash for integrity
|
| 67 |
-
with open(audio_path, 'rb') as f:
|
| 68 |
-
validation['file_hash'] = hashlib.md5(f.read()).hexdigest()
|
| 69 |
-
|
| 70 |
-
# If no errors, mark as valid
|
| 71 |
-
if not validation['errors']:
|
| 72 |
-
validation['is_valid'] = True
|
| 73 |
-
|
| 74 |
-
except Exception as e:
|
| 75 |
-
validation['errors'].append(f'Audio loading error: {str(e)}')
|
| 76 |
-
|
| 77 |
-
except Exception as e:
|
| 78 |
-
validation['errors'].append(f'Validation error: {str(e)}')
|
| 79 |
-
|
| 80 |
-
return validation
|
| 81 |
-
|
| 82 |
-
def validate_batch(self, input_dir: str, report_file: str) -> Dict[str, Any]:
|
| 83 |
-
"""
|
| 84 |
-
Validate all audio files in directory
|
| 85 |
-
|
| 86 |
-
Args:
|
| 87 |
-
input_dir: Directory containing audio files
|
| 88 |
-
report_file: Path to save validation report
|
| 89 |
-
|
| 90 |
-
Returns:
|
| 91 |
-
Dict with batch validation summary
|
| 92 |
-
"""
|
| 93 |
-
input_path = Path(input_dir)
|
| 94 |
-
validation_results = []
|
| 95 |
-
summary = {
|
| 96 |
-
'total_files': 0,
|
| 97 |
-
'valid_files': 0,
|
| 98 |
-
'invalid_files': 0,
|
| 99 |
-
'warnings': 0,
|
| 100 |
-
'errors': []
|
| 101 |
-
}
|
| 102 |
-
|
| 103 |
-
# Validate each audio file
|
| 104 |
-
for audio_file in input_path.rglob('*'):
|
| 105 |
-
if audio_file.suffix.lower() in self.supported_formats:
|
| 106 |
-
result = self.validate_audio_file(str(audio_file))
|
| 107 |
-
validation_results.append(result)
|
| 108 |
-
summary['total_files'] += 1
|
| 109 |
-
|
| 110 |
-
if result['is_valid']:
|
| 111 |
-
summary['valid_files'] += 1
|
| 112 |
-
else:
|
| 113 |
-
summary['invalid_files'] += 1
|
| 114 |
-
summary['errors'].extend(result['errors'])
|
| 115 |
-
|
| 116 |
-
summary['warnings'] += len(result['warnings'])
|
| 117 |
-
|
| 118 |
-
# Generate report
|
| 119 |
-
report = {
|
| 120 |
-
'summary': summary,
|
| 121 |
-
'detailed_results': validation_results,
|
| 122 |
-
'timestamp': str(Path().absolute())
|
| 123 |
-
}
|
| 124 |
-
|
| 125 |
-
# Save report
|
| 126 |
-
with open(report_file, 'w') as f:
|
| 127 |
-
json.dump(report, f, indent=2)
|
| 128 |
-
|
| 129 |
-
return summary
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
processors/format_converter.py
DELETED
|
@@ -1,67 +0,0 @@
|
|
| 1 |
-
"""
|
| 2 |
-
Audio AI Projects - Advanced Audio Processing System
|
| 3 |
-
Copyright (c) 2025 Antonino Mainenti (ninuxi)
|
| 4 |
-
Licensed under MIT License - see LICENSE file
|
| 5 |
-
GitHub: https://github.com/ninuxi/audio-ai-projects
|
| 6 |
-
"""
|
| 7 |
-
import librosa
|
| 8 |
-
import soundfile as sf
|
| 9 |
-
from pathlib import Path
|
| 10 |
-
import subprocess
|
| 11 |
-
|
| 12 |
-
class FormatConverter:
|
| 13 |
-
"""Convert audio between different formats"""
|
| 14 |
-
|
| 15 |
-
def __init__(self):
|
| 16 |
-
self.supported_formats = ['.wav', '.mp3', '.flac', '.ogg', '.m4a']
|
| 17 |
-
|
| 18 |
-
def convert_format(self, input_path: str, output_path: str,
|
| 19 |
-
target_format: str = 'wav') -> bool:
|
| 20 |
-
"""
|
| 21 |
-
Convert audio file to target format
|
| 22 |
-
|
| 23 |
-
Args:
|
| 24 |
-
input_path: Input audio file path
|
| 25 |
-
output_path: Output audio file path
|
| 26 |
-
target_format: Target audio format
|
| 27 |
-
|
| 28 |
-
Returns:
|
| 29 |
-
bool: Success status
|
| 30 |
-
"""
|
| 31 |
-
try:
|
| 32 |
-
# Load and resave in target format
|
| 33 |
-
audio, sr = librosa.load(input_path, sr=None)
|
| 34 |
-
|
| 35 |
-
# Set output path with correct extension
|
| 36 |
-
output_file = Path(output_path).with_suffix(f'.{target_format}')
|
| 37 |
-
|
| 38 |
-
# Save in target format
|
| 39 |
-
sf.write(str(output_file), audio, sr, format=target_format.upper())
|
| 40 |
-
return True
|
| 41 |
-
|
| 42 |
-
except Exception as e:
|
| 43 |
-
print(f"Format conversion error: {e}")
|
| 44 |
-
return False
|
| 45 |
-
|
| 46 |
-
def batch_convert(self, input_dir: str, output_dir: str,
|
| 47 |
-
target_format: str = 'wav') -> int:
|
| 48 |
-
"""
|
| 49 |
-
Convert all audio files in directory
|
| 50 |
-
|
| 51 |
-
Returns:
|
| 52 |
-
int: Number of successfully converted files
|
| 53 |
-
"""
|
| 54 |
-
input_path = Path(input_dir)
|
| 55 |
-
output_path = Path(output_dir)
|
| 56 |
-
output_path.mkdir(exist_ok=True)
|
| 57 |
-
|
| 58 |
-
converted_count = 0
|
| 59 |
-
|
| 60 |
-
for audio_file in input_path.rglob('*'):
|
| 61 |
-
if audio_file.suffix.lower() in self.supported_formats:
|
| 62 |
-
output_file = output_path / f"{audio_file.stem}.{target_format}"
|
| 63 |
-
|
| 64 |
-
if self.convert_format(str(audio_file), str(output_file), target_format):
|
| 65 |
-
converted_count += 1
|
| 66 |
-
|
| 67 |
-
return converted_count
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
processors/init.py
DELETED
|
@@ -1,22 +0,0 @@
|
|
| 1 |
-
"""
|
| 2 |
-
Audio AI Projects - Advanced Audio Processing System
|
| 3 |
-
Copyright (c) 2025 Antonino Mainenti (ninuxi)
|
| 4 |
-
Licensed under MIT License - see LICENSE file
|
| 5 |
-
GitHub: https://github.com/ninuxi/audio-ai-projects
|
| 6 |
-
"""
|
| 7 |
-
"""
|
| 8 |
-
Audio processing modules for batch operations
|
| 9 |
-
"""
|
| 10 |
-
from .audio_normalizer import AudioNormalizer
|
| 11 |
-
from .noise_reducer import NoiseReducer
|
| 12 |
-
from .format_converter import FormatConverter
|
| 13 |
-
from .metadata_extractor import MetadataExtractor
|
| 14 |
-
from .batch_validator import BatchValidator
|
| 15 |
-
|
| 16 |
-
__all__ = [
|
| 17 |
-
'AudioNormalizer',
|
| 18 |
-
'NoiseReducer',
|
| 19 |
-
'FormatConverter',
|
| 20 |
-
'MetadataExtractor',
|
| 21 |
-
'BatchValidator'
|
| 22 |
-
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
processors/metadata_extractor.py
DELETED
|
@@ -1,95 +0,0 @@
|
|
| 1 |
-
"""
|
| 2 |
-
Audio AI Projects - Advanced Audio Processing System
|
| 3 |
-
Copyright (c) 2025 Antonino Mainenti (ninuxi)
|
| 4 |
-
Licensed under MIT License - see LICENSE file
|
| 5 |
-
GitHub: https://github.com/ninuxi/audio-ai-projects
|
| 6 |
-
"""
|
| 7 |
-
import librosa
|
| 8 |
-
import mutagen
|
| 9 |
-
from mutagen.id3 import ID3NoHeaderError
|
| 10 |
-
from pathlib import Path
|
| 11 |
-
import json
|
| 12 |
-
from typing import Dict, Any
|
| 13 |
-
|
| 14 |
-
class MetadataExtractor:
|
| 15 |
-
"""Extract technical and descriptive metadata from audio files"""
|
| 16 |
-
|
| 17 |
-
def extract_audio_metadata(self, audio_path: str) -> Dict[str, Any]:
|
| 18 |
-
"""
|
| 19 |
-
Extract comprehensive metadata from audio file
|
| 20 |
-
|
| 21 |
-
Args:
|
| 22 |
-
audio_path: Path to audio file
|
| 23 |
-
|
| 24 |
-
Returns:
|
| 25 |
-
Dict containing metadata
|
| 26 |
-
"""
|
| 27 |
-
metadata = {}
|
| 28 |
-
|
| 29 |
-
try:
|
| 30 |
-
# Load audio for technical analysis
|
| 31 |
-
audio, sr = librosa.load(audio_path, sr=None)
|
| 32 |
-
|
| 33 |
-
# Technical metadata
|
| 34 |
-
metadata['technical'] = {
|
| 35 |
-
'duration': len(audio) / sr,
|
| 36 |
-
'sample_rate': sr,
|
| 37 |
-
'channels': 1 if len(audio.shape) == 1 else audio.shape[0],
|
| 38 |
-
'bit_depth': 'Unknown',
|
| 39 |
-
'file_size': Path(audio_path).stat().st_size,
|
| 40 |
-
'format': Path(audio_path).suffix.lower()
|
| 41 |
-
}
|
| 42 |
-
|
| 43 |
-
# Audio analysis
|
| 44 |
-
metadata['analysis'] = {
|
| 45 |
-
'rms_energy': float(np.sqrt(np.mean(audio**2))),
|
| 46 |
-
'zero_crossing_rate': float(np.mean(librosa.feature.zero_crossing_rate(audio))),
|
| 47 |
-
'spectral_centroid': float(np.mean(librosa.feature.spectral_centroid(audio, sr=sr))),
|
| 48 |
-
'tempo': float(librosa.tempo(audio, sr=sr)[0])
|
| 49 |
-
}
|
| 50 |
-
|
| 51 |
-
# File metadata using mutagen
|
| 52 |
-
try:
|
| 53 |
-
file_metadata = mutagen.File(audio_path)
|
| 54 |
-
if file_metadata:
|
| 55 |
-
metadata['tags'] = {
|
| 56 |
-
'title': str(file_metadata.get('TIT2', ['Unknown'])[0]) if 'TIT2' in file_metadata else 'Unknown',
|
| 57 |
-
'artist': str(file_metadata.get('TPE1', ['Unknown'])[0]) if 'TPE1' in file_metadata else 'Unknown',
|
| 58 |
-
'album': str(file_metadata.get('TALB', ['Unknown'])[0]) if 'TALB' in file_metadata else 'Unknown',
|
| 59 |
-
'date': str(file_metadata.get('TDRC', ['Unknown'])[0]) if 'TDRC' in file_metadata else 'Unknown'
|
| 60 |
-
}
|
| 61 |
-
except (ID3NoHeaderError, Exception):
|
| 62 |
-
metadata['tags'] = {
|
| 63 |
-
'title': Path(audio_path).stem,
|
| 64 |
-
'artist': 'Unknown',
|
| 65 |
-
'album': 'Unknown',
|
| 66 |
-
'date': 'Unknown'
|
| 67 |
-
}
|
| 68 |
-
|
| 69 |
-
except Exception as e:
|
| 70 |
-
metadata['error'] = str(e)
|
| 71 |
-
|
| 72 |
-
return metadata
|
| 73 |
-
|
| 74 |
-
def batch_extract_metadata(self, input_dir: str, output_file: str) -> int:
|
| 75 |
-
"""
|
| 76 |
-
Extract metadata from all audio files in directory
|
| 77 |
-
|
| 78 |
-
Returns:
|
| 79 |
-
int: Number of processed files
|
| 80 |
-
"""
|
| 81 |
-
input_path = Path(input_dir)
|
| 82 |
-
all_metadata = {}
|
| 83 |
-
processed_count = 0
|
| 84 |
-
|
| 85 |
-
for audio_file in input_path.rglob('*'):
|
| 86 |
-
if audio_file.suffix.lower() in ['.wav', '.mp3', '.flac', '.ogg', '.m4a']:
|
| 87 |
-
file_metadata = self.extract_audio_metadata(str(audio_file))
|
| 88 |
-
all_metadata[str(audio_file)] = file_metadata
|
| 89 |
-
processed_count += 1
|
| 90 |
-
|
| 91 |
-
# Save metadata to JSON file
|
| 92 |
-
with open(output_file, 'w') as f:
|
| 93 |
-
json.dump(all_metadata, f, indent=2)
|
| 94 |
-
|
| 95 |
-
return processed_count
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
processors/noise_reducer.py
DELETED
|
@@ -1,49 +0,0 @@
|
|
| 1 |
-
"""
|
| 2 |
-
Audio AI Projects - Advanced Audio Processing System
|
| 3 |
-
Copyright (c) 2025 Antonino Mainenti (ninuxi)
|
| 4 |
-
Licensed under MIT License - see LICENSE file
|
| 5 |
-
GitHub: https://github.com/ninuxi/audio-ai-projects
|
| 6 |
-
"""
|
| 7 |
-
import librosa
|
| 8 |
-
import soundfile as sf
|
| 9 |
-
import numpy as np
|
| 10 |
-
from scipy.signal import wiener
|
| 11 |
-
|
| 12 |
-
class NoiseReducer:
|
| 13 |
-
"""Reduce background noise from audio"""
|
| 14 |
-
|
| 15 |
-
def __init__(self):
|
| 16 |
-
self.noise_threshold = 0.1
|
| 17 |
-
|
| 18 |
-
def reduce_noise(self, audio_path: str, output_path: str) -> bool:
|
| 19 |
-
"""
|
| 20 |
-
Apply noise reduction to audio file
|
| 21 |
-
|
| 22 |
-
Args:
|
| 23 |
-
audio_path: Input audio file path
|
| 24 |
-
output_path: Output cleaned audio path
|
| 25 |
-
|
| 26 |
-
Returns:
|
| 27 |
-
bool: Success status
|
| 28 |
-
"""
|
| 29 |
-
try:
|
| 30 |
-
# Load audio
|
| 31 |
-
audio, sr = librosa.load(audio_path, sr=None)
|
| 32 |
-
|
| 33 |
-
# Estimate noise from first 0.5 seconds
|
| 34 |
-
noise_sample = audio[:int(0.5 * sr)]
|
| 35 |
-
noise_level = np.std(noise_sample)
|
| 36 |
-
|
| 37 |
-
# Apply Wiener filter for noise reduction
|
| 38 |
-
if noise_level > self.noise_threshold:
|
| 39 |
-
filtered_audio = wiener(audio, mysize=5)
|
| 40 |
-
else:
|
| 41 |
-
filtered_audio = audio
|
| 42 |
-
|
| 43 |
-
# Save cleaned audio
|
| 44 |
-
sf.write(output_path, filtered_audio, sr)
|
| 45 |
-
return True
|
| 46 |
-
|
| 47 |
-
except Exception as e:
|
| 48 |
-
print(f"Noise reduction error for {audio_path}: {e}")
|
| 49 |
-
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reports/__pycache__/batch_report_generator.cpython-313.pyc
DELETED
|
Binary file (8.67 kB)
|
|
|
reports/__pycache__/processing_stats.cpython-313.pyc
DELETED
|
Binary file (9.01 kB)
|
|
|
reports/__pycache__/quality_analyzer.cpython-313.pyc
DELETED
|
Binary file (7.68 kB)
|
|
|
reports/batch_report_generator.py
DELETED
|
@@ -1,131 +0,0 @@
|
|
| 1 |
-
"""
|
| 2 |
-
Audio AI Projects - Advanced Audio Processing System
|
| 3 |
-
Copyright (c) 2025 Antonino Mainenti (ninuxi)
|
| 4 |
-
Licensed under MIT License - see LICENSE file
|
| 5 |
-
GitHub: https://github.com/ninuxi/audio-ai-projects
|
| 6 |
-
"""
|
| 7 |
-
import json
|
| 8 |
-
from pathlib import Path
|
| 9 |
-
from datetime import datetime
|
| 10 |
-
from typing import Dict, List, Any
|
| 11 |
-
import matplotlib.pyplot as plt
|
| 12 |
-
import seaborn as sns
|
| 13 |
-
|
| 14 |
-
class BatchReportGenerator:
|
| 15 |
-
"""Generate comprehensive reports for batch processing operations"""
|
| 16 |
-
|
| 17 |
-
def __init__(self, output_dir: str = "reports"):
|
| 18 |
-
self.output_dir = Path(output_dir)
|
| 19 |
-
self.output_dir.mkdir(exist_ok=True)
|
| 20 |
-
|
| 21 |
-
def generate_processing_report(self, results: Dict[str, Any],
|
| 22 |
-
report_name: str = "batch_processing_report") -> str:
|
| 23 |
-
"""
|
| 24 |
-
Generate detailed processing report
|
| 25 |
-
|
| 26 |
-
Args:
|
| 27 |
-
results: Processing results dictionary
|
| 28 |
-
report_name: Name of the report file
|
| 29 |
-
|
| 30 |
-
Returns:
|
| 31 |
-
str: Path to generated report
|
| 32 |
-
"""
|
| 33 |
-
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
| 34 |
-
report_path = self.output_dir / f"{report_name}_{timestamp}.md"
|
| 35 |
-
|
| 36 |
-
with open(report_path, 'w') as f:
|
| 37 |
-
# Header
|
| 38 |
-
f.write(f"# Batch Processing Report\n")
|
| 39 |
-
f.write(f"**Generated:** {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n\n")
|
| 40 |
-
|
| 41 |
-
# Summary
|
| 42 |
-
f.write("## Processing Summary\n")
|
| 43 |
-
if 'summary' in results:
|
| 44 |
-
summary = results['summary']
|
| 45 |
-
f.write(f"- **Total Files Processed:** {summary.get('total_files', 0)}\n")
|
| 46 |
-
f.write(f"- **Successfully Processed:** {summary.get('successful', 0)}\n")
|
| 47 |
-
f.write(f"- **Failed:** {summary.get('failed', 0)}\n")
|
| 48 |
-
f.write(f"- **Success Rate:** {summary.get('success_rate', 0):.1f}%\n")
|
| 49 |
-
f.write(f"- **Total Processing Time:** {summary.get('total_time', 0):.2f} seconds\n\n")
|
| 50 |
-
|
| 51 |
-
# Detailed Results
|
| 52 |
-
if 'detailed_results' in results:
|
| 53 |
-
f.write("## Detailed Results\n")
|
| 54 |
-
for result in results['detailed_results']:
|
| 55 |
-
f.write(f"### {Path(result['file']).name}\n")
|
| 56 |
-
f.write(f"- **Status:** {result['status']}\n")
|
| 57 |
-
f.write(f"- **Processing Time:** {result.get('time', 0):.2f}s\n")
|
| 58 |
-
if result.get('errors'):
|
| 59 |
-
f.write(f"- **Errors:** {'; '.join(result['errors'])}\n")
|
| 60 |
-
f.write("\n")
|
| 61 |
-
|
| 62 |
-
# Quality Analysis
|
| 63 |
-
if 'quality_metrics' in results:
|
| 64 |
-
f.write("## Quality Analysis\n")
|
| 65 |
-
metrics = results['quality_metrics']
|
| 66 |
-
f.write(f"- **Average SNR:** {metrics.get('avg_snr', 0):.2f} dB\n")
|
| 67 |
-
f.write(f"- **Average RMS Level:** {metrics.get('avg_rms', 0):.4f}\n")
|
| 68 |
-
f.write(f"- **Dynamic Range:** {metrics.get('dynamic_range', 0):.2f} dB\n\n")
|
| 69 |
-
|
| 70 |
-
# Recommendations
|
| 71 |
-
f.write("## Recommendations\n")
|
| 72 |
-
if results.get('failed', 0) > 0:
|
| 73 |
-
f.write("- Review failed files for format compatibility issues\n")
|
| 74 |
-
if results.get('quality_metrics', {}).get('avg_snr', 0) < 20:
|
| 75 |
-
f.write("- Consider applying noise reduction to improve SNR\n")
|
| 76 |
-
f.write("- Archive original files before processing\n")
|
| 77 |
-
f.write("- Validate processing results before deployment\n")
|
| 78 |
-
|
| 79 |
-
return str(report_path)
|
| 80 |
-
|
| 81 |
-
def generate_visualization_report(self, results: Dict[str, Any]) -> str:
|
| 82 |
-
"""Generate visual analytics report"""
|
| 83 |
-
|
| 84 |
-
# Create processing time distribution
|
| 85 |
-
if 'detailed_results' in results:
|
| 86 |
-
processing_times = [r.get('time', 0) for r in results['detailed_results']]
|
| 87 |
-
|
| 88 |
-
plt.figure(figsize=(12, 8))
|
| 89 |
-
|
| 90 |
-
# Processing time histogram
|
| 91 |
-
plt.subplot(2, 2, 1)
|
| 92 |
-
plt.hist(processing_times, bins=20, alpha=0.7, color='blue')
|
| 93 |
-
plt.title('Processing Time Distribution')
|
| 94 |
-
plt.xlabel('Time (seconds)')
|
| 95 |
-
plt.ylabel('Frequency')
|
| 96 |
-
|
| 97 |
-
# Success/Failure pie chart
|
| 98 |
-
plt.subplot(2, 2, 2)
|
| 99 |
-
success_count = sum(1 for r in results['detailed_results'] if r['status'] == 'success')
|
| 100 |
-
failed_count = len(results['detailed_results']) - success_count
|
| 101 |
-
plt.pie([success_count, failed_count], labels=['Success', 'Failed'],
|
| 102 |
-
autopct='%1.1f%%', colors=['green', 'red'])
|
| 103 |
-
plt.title('Processing Success Rate')
|
| 104 |
-
|
| 105 |
-
# File size distribution (if available)
|
| 106 |
-
if 'quality_metrics' in results:
|
| 107 |
-
plt.subplot(2, 2, 3)
|
| 108 |
-
file_sizes = [r.get('file_size', 0) for r in results['detailed_results']]
|
| 109 |
-
plt.boxplot(file_sizes)
|
| 110 |
-
plt.title('File Size Distribution')
|
| 111 |
-
plt.ylabel('Size (bytes)')
|
| 112 |
-
|
| 113 |
-
# Processing efficiency
|
| 114 |
-
plt.subplot(2, 2, 4)
|
| 115 |
-
file_names = [Path(r['file']).name[:10] for r in results['detailed_results'][:10]]
|
| 116 |
-
times = processing_times[:10]
|
| 117 |
-
plt.barh(file_names, times)
|
| 118 |
-
plt.title('Processing Time by File (Top 10)')
|
| 119 |
-
plt.xlabel('Time (seconds)')
|
| 120 |
-
|
| 121 |
-
plt.tight_layout()
|
| 122 |
-
|
| 123 |
-
# Save plot
|
| 124 |
-
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
| 125 |
-
plot_path = self.output_dir / f"processing_analytics_{timestamp}.png"
|
| 126 |
-
plt.savefig(plot_path, dpi=300, bbox_inches='tight')
|
| 127 |
-
plt.close()
|
| 128 |
-
|
| 129 |
-
return str(plot_path)
|
| 130 |
-
|
| 131 |
-
return ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reports/init.py
DELETED
|
@@ -1,18 +0,0 @@
|
|
| 1 |
-
"""
|
| 2 |
-
Audio AI Projects - Advanced Audio Processing System
|
| 3 |
-
Copyright (c) 2025 Antonino Mainenti (ninuxi)
|
| 4 |
-
Licensed under MIT License - see LICENSE file
|
| 5 |
-
GitHub: https://github.com/ninuxi/audio-ai-projects
|
| 6 |
-
"""
|
| 7 |
-
"""
|
| 8 |
-
Reporting modules for batch processing analysis
|
| 9 |
-
"""
|
| 10 |
-
from .batch_report_generator import BatchReportGenerator
|
| 11 |
-
from .quality_analyzer import QualityAnalyzer
|
| 12 |
-
from .processing_stats import ProcessingStats
|
| 13 |
-
|
| 14 |
-
__all__ = [
|
| 15 |
-
'BatchReportGenerator',
|
| 16 |
-
'QualityAnalyzer',
|
| 17 |
-
'ProcessingStats'
|
| 18 |
-
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reports/processing_stats.py
DELETED
|
@@ -1,179 +0,0 @@
|
|
| 1 |
-
"""
|
| 2 |
-
Audio AI Projects - Advanced Audio Processing System
|
| 3 |
-
Copyright (c) 2025 Antonino Mainenti (ninuxi)
|
| 4 |
-
Licensed under MIT License - see LICENSE file
|
| 5 |
-
GitHub: https://github.com/ninuxi/audio-ai-projects
|
| 6 |
-
"""
|
| 7 |
-
import time
|
| 8 |
-
import json
|
| 9 |
-
from pathlib import Path
|
| 10 |
-
from datetime import datetime
|
| 11 |
-
from typing import Dict, List, Any, Optional
|
| 12 |
-
|
| 13 |
-
class ProcessingStats:
|
| 14 |
-
"""Track and analyze processing statistics for batch operations"""
|
| 15 |
-
|
| 16 |
-
def __init__(self):
|
| 17 |
-
self.processing_history = []
|
| 18 |
-
self.current_batch = None
|
| 19 |
-
|
| 20 |
-
def start_batch(self, batch_name: str, total_files: int) -> None:
|
| 21 |
-
"""Initialize new batch processing session"""
|
| 22 |
-
self.current_batch = {
|
| 23 |
-
'batch_name': batch_name,
|
| 24 |
-
'start_time': time.time(),
|
| 25 |
-
'total_files': total_files,
|
| 26 |
-
'processed_files': 0,
|
| 27 |
-
'successful_files': 0,
|
| 28 |
-
'failed_files': 0,
|
| 29 |
-
'processing_times': [],
|
| 30 |
-
'errors': [],
|
| 31 |
-
'file_details': []
|
| 32 |
-
}
|
| 33 |
-
|
| 34 |
-
def record_file_processing(self, file_path: str, success: bool,
|
| 35 |
-
processing_time: float, error: Optional[str] = None) -> None:
|
| 36 |
-
"""Record processing result for individual file"""
|
| 37 |
-
if self.current_batch is None:
|
| 38 |
-
return
|
| 39 |
-
|
| 40 |
-
self.current_batch['processed_files'] += 1
|
| 41 |
-
self.current_batch['processing_times'].append(processing_time)
|
| 42 |
-
|
| 43 |
-
file_record = {
|
| 44 |
-
'file_path': file_path,
|
| 45 |
-
'success': success,
|
| 46 |
-
'processing_time': processing_time,
|
| 47 |
-
'timestamp': datetime.now().isoformat()
|
| 48 |
-
}
|
| 49 |
-
|
| 50 |
-
if success:
|
| 51 |
-
self.current_batch['successful_files'] += 1
|
| 52 |
-
else:
|
| 53 |
-
self.current_batch['failed_files'] += 1
|
| 54 |
-
if error:
|
| 55 |
-
file_record['error'] = error
|
| 56 |
-
self.current_batch['errors'].append(f"{Path(file_path).name}: {error}")
|
| 57 |
-
|
| 58 |
-
self.current_batch['file_details'].append(file_record)
|
| 59 |
-
|
| 60 |
-
def finish_batch(self) -> Dict[str, Any]:
|
| 61 |
-
"""Complete batch processing and calculate final statistics"""
|
| 62 |
-
if self.current_batch is None:
|
| 63 |
-
return {}
|
| 64 |
-
|
| 65 |
-
end_time = time.time()
|
| 66 |
-
total_time = end_time - self.current_batch['start_time']
|
| 67 |
-
|
| 68 |
-
# Calculate statistics
|
| 69 |
-
processing_times = self.current_batch['processing_times']
|
| 70 |
-
batch_results = {
|
| 71 |
-
'batch_name': self.current_batch['batch_name'],
|
| 72 |
-
'total_processing_time': total_time,
|
| 73 |
-
'total_files': self.current_batch['total_files'],
|
| 74 |
-
'processed_files': self.current_batch['processed_files'],
|
| 75 |
-
'successful_files': self.current_batch['successful_files'],
|
| 76 |
-
'failed_files': self.current_batch['failed_files'],
|
| 77 |
-
'success_rate': (self.current_batch['successful_files'] / max(1, self.current_batch['processed_files'])) * 100,
|
| 78 |
-
'average_processing_time': sum(processing_times) / max(1, len(processing_times)),
|
| 79 |
-
'min_processing_time': min(processing_times) if processing_times else 0,
|
| 80 |
-
'max_processing_time': max(processing_times) if processing_times else 0,
|
| 81 |
-
'throughput': self.current_batch['processed_files'] / max(1, total_time), # files per second
|
| 82 |
-
'errors': self.current_batch['errors'],
|
| 83 |
-
'file_details': self.current_batch['file_details'],
|
| 84 |
-
'completion_time': datetime.now().isoformat()
|
| 85 |
-
}
|
| 86 |
-
|
| 87 |
-
# Add to processing history
|
| 88 |
-
self.processing_history.append(batch_results)
|
| 89 |
-
|
| 90 |
-
# Reset current batch
|
| 91 |
-
self.current_batch = None
|
| 92 |
-
|
| 93 |
-
return batch_results
|
| 94 |
-
|
| 95 |
-
def get_processing_efficiency(self) -> Dict[str, Any]:
|
| 96 |
-
"""Analyze processing efficiency across batches"""
|
| 97 |
-
if not self.processing_history:
|
| 98 |
-
return {'message': 'No processing history available'}
|
| 99 |
-
|
| 100 |
-
efficiency_stats = {
|
| 101 |
-
'total_batches': len(self.processing_history),
|
| 102 |
-
'total_files_processed': sum(b['processed_files'] for b in self.processing_history),
|
| 103 |
-
'overall_success_rate': 0,
|
| 104 |
-
'average_throughput': 0,
|
| 105 |
-
'performance_trends': [],
|
| 106 |
-
'bottlenecks': []
|
| 107 |
-
}
|
| 108 |
-
|
| 109 |
-
# Calculate overall metrics
|
| 110 |
-
total_successful = sum(b['successful_files'] for b in self.processing_history)
|
| 111 |
-
total_processed = sum(b['processed_files'] for b in self.processing_history)
|
| 112 |
-
|
| 113 |
-
if total_processed > 0:
|
| 114 |
-
efficiency_stats['overall_success_rate'] = (total_successful / total_processed) * 100
|
| 115 |
-
|
| 116 |
-
# Average throughput
|
| 117 |
-
throughputs = [b['throughput'] for b in self.processing_history]
|
| 118 |
-
efficiency_stats['average_throughput'] = sum(throughputs) / len(throughputs)
|
| 119 |
-
|
| 120 |
-
# Performance trends
|
| 121 |
-
for i, batch in enumerate(self.processing_history):
|
| 122 |
-
efficiency_stats['performance_trends'].append({
|
| 123 |
-
'batch_number': i + 1,
|
| 124 |
-
'batch_name': batch['batch_name'],
|
| 125 |
-
'success_rate': batch['success_rate'],
|
| 126 |
-
'throughput': batch['throughput'],
|
| 127 |
-
'average_time': batch['average_processing_time']
|
| 128 |
-
})
|
| 129 |
-
|
| 130 |
-
# Identify bottlenecks
|
| 131 |
-
slow_batches = [b for b in self.processing_history if b['average_processing_time'] > 5.0]
|
| 132 |
-
if slow_batches:
|
| 133 |
-
efficiency_stats['bottlenecks'].append(f"Slow processing detected in {len(slow_batches)} batches")
|
| 134 |
-
|
| 135 |
-
low_success_batches = [b for b in self.processing_history if b['success_rate'] < 90]
|
| 136 |
-
if low_success_batches:
|
| 137 |
-
efficiency_stats['bottlenecks'].append(f"Low success rate in {len(low_success_batches)} batches")
|
| 138 |
-
|
| 139 |
-
return efficiency_stats
|
| 140 |
-
|
| 141 |
-
def save_processing_report(self, output_file: str) -> str:
|
| 142 |
-
"""Save comprehensive processing report"""
|
| 143 |
-
report = {
|
| 144 |
-
'processing_history': self.processing_history,
|
| 145 |
-
'efficiency_analysis': self.get_processing_efficiency(),
|
| 146 |
-
'report_generated': datetime.now().isoformat()
|
| 147 |
-
}
|
| 148 |
-
|
| 149 |
-
with open(output_file, 'w') as f:
|
| 150 |
-
json.dump(report, f, indent=2)
|
| 151 |
-
|
| 152 |
-
return output_file
|
| 153 |
-
|
| 154 |
-
def get_current_progress(self) -> Dict[str, Any]:
|
| 155 |
-
"""Get current batch processing progress"""
|
| 156 |
-
if self.current_batch is None:
|
| 157 |
-
return {'message': 'No active batch processing'}
|
| 158 |
-
|
| 159 |
-
elapsed_time = time.time() - self.current_batch['start_time']
|
| 160 |
-
processed = self.current_batch['processed_files']
|
| 161 |
-
total = self.current_batch['total_files']
|
| 162 |
-
|
| 163 |
-
progress = {
|
| 164 |
-
'batch_name': self.current_batch['batch_name'],
|
| 165 |
-
'progress_percentage': (processed / max(1, total)) * 100,
|
| 166 |
-
'processed_files': processed,
|
| 167 |
-
'total_files': total,
|
| 168 |
-
'elapsed_time': elapsed_time,
|
| 169 |
-
'estimated_remaining_time': 0,
|
| 170 |
-
'current_success_rate': (self.current_batch['successful_files'] / max(1, processed)) * 100
|
| 171 |
-
}
|
| 172 |
-
|
| 173 |
-
# Estimate remaining time
|
| 174 |
-
if processed > 0:
|
| 175 |
-
avg_time_per_file = elapsed_time / processed
|
| 176 |
-
remaining_files = total - processed
|
| 177 |
-
progress['estimated_remaining_time'] = avg_time_per_file * remaining_files
|
| 178 |
-
|
| 179 |
-
return progress
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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https://github.com/ninuxi/audio-ai-projects
|
| 6 |
-
"""
|
| 7 |
-
import librosa
|
| 8 |
-
import numpy as np
|
| 9 |
-
from pathlib import Path
|
| 10 |
-
import json
|
| 11 |
-
from typing import Dict, List, Any
|
| 12 |
-
|
| 13 |
-
class QualityAnalyzer:
|
| 14 |
-
"""Analyze audio quality metrics across batch processing"""
|
| 15 |
-
|
| 16 |
-
def __init__(self):
|
| 17 |
-
self.quality_thresholds = {
|
| 18 |
-
'min_snr': 10, # dB
|
| 19 |
-
'max_clipping': 0.01, # 1% clipping threshold
|
| 20 |
-
'min_dynamic_range': 20, # dB
|
| 21 |
-
'max_silence_ratio': 0.1 # 10% silence
|
| 22 |
-
}
|
| 23 |
-
|
| 24 |
-
# reports/quality_analyzer.py
|
| 25 |
-
|
| 26 |
-
def analyze_audio_quality(self, audio_path: str) -> Dict[str, Any]:
|
| 27 |
-
"""
|
| 28 |
-
Analyze quality metrics for single audio file
|
| 29 |
-
|
| 30 |
-
Args:
|
| 31 |
-
audio_path: Path to audio file
|
| 32 |
-
|
| 33 |
-
Returns:
|
| 34 |
-
Dict with quality metrics
|
| 35 |
-
"""
|
| 36 |
-
quality_metrics = {
|
| 37 |
-
'file_path': audio_path,
|
| 38 |
-
'snr': 0.0,
|
| 39 |
-
'dynamic_range': 0.0,
|
| 40 |
-
'clipping_ratio': 0.0,
|
| 41 |
-
'silence_ratio': 0.0,
|
| 42 |
-
'rms_level': 0.0,
|
| 43 |
-
'peak_level': 0.0,
|
| 44 |
-
'quality_score': 0.0,
|
| 45 |
-
'issues': []
|
| 46 |
-
}
|
| 47 |
-
|
| 48 |
-
try:
|
| 49 |
-
# Load audio
|
| 50 |
-
audio, sr = librosa.load(audio_path, sr=None, mono=True)
|
| 51 |
-
|
| 52 |
-
# Evita errori con file vuoti o troppo corti
|
| 53 |
-
if len(audio) < sr * 0.1:
|
| 54 |
-
quality_metrics['issues'].append('Audio too short for analysis')
|
| 55 |
-
return quality_metrics
|
| 56 |
-
|
| 57 |
-
# Metrics calculation
|
| 58 |
-
peak_level = np.max(np.abs(audio))
|
| 59 |
-
rms_level = np.sqrt(np.mean(audio**2))
|
| 60 |
-
|
| 61 |
-
# Evita divisione per zero se RMS è 0 (silenzio)
|
| 62 |
-
if rms_level > 0:
|
| 63 |
-
dynamic_range = 20 * np.log10(peak_level / rms_level)
|
| 64 |
-
|
| 65 |
-
# Simple SNR estimation (signal vs. noise floor)
|
| 66 |
-
noise_floor = np.mean(audio[audio < 0.01]) if np.any(audio < 0.01) else 1e-6
|
| 67 |
-
if noise_floor > 0:
|
| 68 |
-
snr = 20 * np.log10(rms_level / noise_floor)
|
| 69 |
-
else:
|
| 70 |
-
snr = 100.0 # High SNR for clean signal
|
| 71 |
-
else:
|
| 72 |
-
dynamic_range = 0.0
|
| 73 |
-
snr = 0.0
|
| 74 |
-
|
| 75 |
-
clipping_ratio = np.sum(np.abs(audio) >= 0.999) / len(audio)
|
| 76 |
-
silence_ratio = np.sum(librosa.effects.split(audio, top_db=40, frame_length=2048, hop_length=512).shape[0] > 0) / (len(audio)/sr)
|
| 77 |
-
|
| 78 |
-
# --- LA CORREZIONE È QUI ---
|
| 79 |
-
# Convertiamo tutti i tipi numpy in float standard per la compatibilità JSON
|
| 80 |
-
quality_metrics['snr'] = float(snr)
|
| 81 |
-
quality_metrics['dynamic_range'] = float(dynamic_range)
|
| 82 |
-
quality_metrics['clipping_ratio'] = float(clipping_ratio)
|
| 83 |
-
quality_metrics['silence_ratio'] = float(silence_ratio)
|
| 84 |
-
quality_metrics['rms_level'] = float(rms_level)
|
| 85 |
-
quality_metrics['peak_level'] = float(peak_level)
|
| 86 |
-
|
| 87 |
-
# Simple quality score
|
| 88 |
-
score = 100
|
| 89 |
-
if snr < self.quality_thresholds['min_snr']:
|
| 90 |
-
quality_metrics['issues'].append(f"Low SNR: {snr:.2f}dB")
|
| 91 |
-
score -= 20
|
| 92 |
-
if clipping_ratio > self.quality_thresholds['max_clipping']:
|
| 93 |
-
quality_metrics['issues'].append(f"Clipping detected: {clipping_ratio*100:.2f}%")
|
| 94 |
-
score -= 30
|
| 95 |
-
|
| 96 |
-
quality_metrics['quality_score'] = float(max(0, score))
|
| 97 |
-
|
| 98 |
-
except Exception as e:
|
| 99 |
-
quality_metrics['issues'].append(f"Analysis error: {str(e)}")
|
| 100 |
-
|
| 101 |
-
return quality_metrics
|
| 102 |
-
|
| 103 |
-
def batch_quality_analysis(self, input_dir: str, output_report: str) -> Dict[str, Any]:
|
| 104 |
-
"""
|
| 105 |
-
Analyze quality for all audio files in directory
|
| 106 |
-
|
| 107 |
-
Returns:
|
| 108 |
-
Dict with batch quality analysis
|
| 109 |
-
"""
|
| 110 |
-
input_path = Path(input_dir)
|
| 111 |
-
quality_results = []
|
| 112 |
-
|
| 113 |
-
# Analyze each file
|
| 114 |
-
for audio_file in input_path.rglob('*'):
|
| 115 |
-
if audio_file.suffix.lower() in ['.wav', '.mp3', '.flac', '.ogg', '.m4a']:
|
| 116 |
-
quality_metrics = self.analyze_audio_quality(str(audio_file))
|
| 117 |
-
quality_results.append(quality_metrics)
|
| 118 |
-
|
| 119 |
-
# Calculate batch statistics
|
| 120 |
-
valid_results = [r for r in quality_results if 'error' not in r]
|
| 121 |
-
|
| 122 |
-
if valid_results:
|
| 123 |
-
batch_stats = {
|
| 124 |
-
'total_files': len(quality_results),
|
| 125 |
-
'analyzed_files': len(valid_results),
|
| 126 |
-
'average_snr': np.mean([r['snr'] for r in valid_results]),
|
| 127 |
-
'average_dynamic_range': np.mean([r['dynamic_range'] for r in valid_results]),
|
| 128 |
-
'average_quality_score': np.mean([r['quality_score'] for r in valid_results]),
|
| 129 |
-
'files_with_issues': len([r for r in valid_results if r['issues']]),
|
| 130 |
-
'common_issues': {}
|
| 131 |
-
}
|
| 132 |
-
|
| 133 |
-
# Count common issues
|
| 134 |
-
all_issues = []
|
| 135 |
-
for result in valid_results:
|
| 136 |
-
all_issues.extend(result['issues'])
|
| 137 |
-
|
| 138 |
-
for issue in set(all_issues):
|
| 139 |
-
batch_stats['common_issues'][issue] = all_issues.count(issue)
|
| 140 |
-
|
| 141 |
-
else:
|
| 142 |
-
batch_stats = {'total_files': len(quality_results), 'analyzed_files': 0}
|
| 143 |
-
|
| 144 |
-
# Generate report
|
| 145 |
-
report = {
|
| 146 |
-
'batch_statistics': batch_stats,
|
| 147 |
-
'individual_results': quality_results,
|
| 148 |
-
'recommendations': self._generate_recommendations(batch_stats)
|
| 149 |
-
}
|
| 150 |
-
|
| 151 |
-
# Save report
|
| 152 |
-
with open(output_report, 'w') as f:
|
| 153 |
-
json.dump(report, f, indent=2)
|
| 154 |
-
|
| 155 |
-
return report
|
| 156 |
-
|
| 157 |
-
def _generate_recommendations(self, batch_stats: Dict[str, Any]) -> List[str]:
|
| 158 |
-
"""Generate quality improvement recommendations"""
|
| 159 |
-
recommendations = []
|
| 160 |
-
|
| 161 |
-
if 'average_snr' in batch_stats:
|
| 162 |
-
if batch_stats['average_snr'] < 15:
|
| 163 |
-
recommendations.append("Consider applying noise reduction to improve SNR")
|
| 164 |
-
|
| 165 |
-
if batch_stats['average_dynamic_range'] < 25:
|
| 166 |
-
recommendations.append("Audio may benefit from dynamic range expansion")
|
| 167 |
-
|
| 168 |
-
if batch_stats['files_with_issues'] > batch_stats['analyzed_files'] * 0.3:
|
| 169 |
-
recommendations.append("High percentage of files with quality issues - review source material")
|
| 170 |
-
|
| 171 |
-
if not recommendations:
|
| 172 |
-
recommendations.append("Audio quality appears acceptable for batch processing")
|
| 173 |
-
|
| 174 |
-
return recommendations
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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0
|
| 10 |
-
torch>=1.12.0
|
| 11 |
-
torchaudio>=0.12.0
|
| 12 |
-
mutagen>=1.47.0
|
| 13 |
-
|
| 14 |
-
# API Libraries
|
| 15 |
-
fastapi
|
| 16 |
-
uvicorn
|
| 17 |
-
python-multipart
|
| 18 |
-
PyYAML
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
requests
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
templates/html_template.html
DELETED
|
@@ -1,69 +0,0 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html lang="en">
|
| 3 |
-
<head>
|
| 4 |
-
<meta charset="UTF-8">
|
| 5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>Batch Processing Report</title>
|
| 7 |
-
<style>
|
| 8 |
-
body { font-family: Arial, sans-serif; margin: 20px; background-color: #f5f5f5; }
|
| 9 |
-
.container { max-width: 1200px; margin: 0 auto; background: white; padding: 30px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
|
| 10 |
-
.header { border-bottom: 2px solid #007bff; padding-bottom: 20px; margin-bottom: 30px; }
|
| 11 |
-
.metric-card { background: #f8f9fa; padding: 20px; margin: 10px; border-radius: 6px; display: inline-block; min-width: 200px; }
|
| 12 |
-
.success { color: #28a745; } .warning { color: #ffc107; } .error { color: #dc3545; }
|
| 13 |
-
table { width: 100%; border-collapse: collapse; margin: 20px 0; }
|
| 14 |
-
th, td { padding: 12px; text-align: left; border-bottom: 1px solid #ddd; }
|
| 15 |
-
th { background-color: #007bff; color: white; }
|
| 16 |
-
.progress-bar { background-color: #e0e0e0; border-radius: 10px; padding: 3px; }
|
| 17 |
-
.progress-fill { background-color: #28a745; height: 20px; border-radius: 8px; transition: width 0.3s; }
|
| 18 |
-
</style>
|
| 19 |
-
</head>
|
| 20 |
-
<body>
|
| 21 |
-
<div class="container">
|
| 22 |
-
<div class="header">
|
| 23 |
-
<h1>Audio Batch Processing Report</h1>
|
| 24 |
-
<p>Generated on: {{timestamp}}</p>
|
| 25 |
-
</div>
|
| 26 |
-
|
| 27 |
-
<div class="metrics-overview">
|
| 28 |
-
<div class="metric-card">
|
| 29 |
-
<h3>Total Files</h3>
|
| 30 |
-
<p style="font-size: 2em; margin: 0;">{{total_files}}</p>
|
| 31 |
-
</div>
|
| 32 |
-
<div class="metric-card">
|
| 33 |
-
<h3>Success Rate</h3>
|
| 34 |
-
<p style="font-size: 2em; margin: 0;" class="success">{{success_rate}}%</p>
|
| 35 |
-
</div>
|
| 36 |
-
<div class="metric-card">
|
| 37 |
-
<h3>Processing Time</h3>
|
| 38 |
-
<p style="font-size: 1.5em; margin: 0;">{{total_time}}s</p>
|
| 39 |
-
</div>
|
| 40 |
-
<div class="metric-card">
|
| 41 |
-
<h3>Throughput</h3>
|
| 42 |
-
<p style="font-size: 1.5em; margin: 0;">{{throughput}} files/s</p>
|
| 43 |
-
</div>
|
| 44 |
-
</div>
|
| 45 |
-
|
| 46 |
-
<h2>Processing Details</h2>
|
| 47 |
-
<table>
|
| 48 |
-
<thead>
|
| 49 |
-
<tr>
|
| 50 |
-
<th>File Name</th>
|
| 51 |
-
<th>Status</th>
|
| 52 |
-
<th>Processing Time</th>
|
| 53 |
-
<th>Issues</th>
|
| 54 |
-
</tr>
|
| 55 |
-
</thead>
|
| 56 |
-
<tbody>
|
| 57 |
-
{{file_details}}
|
| 58 |
-
</tbody>
|
| 59 |
-
</table>
|
| 60 |
-
|
| 61 |
-
<div class="recommendations">
|
| 62 |
-
<h2>Recommendations</h2>
|
| 63 |
-
<ul>
|
| 64 |
-
{{recommendations}}
|
| 65 |
-
</ul>
|
| 66 |
-
</div>
|
| 67 |
-
</div>
|
| 68 |
-
</body>
|
| 69 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
templates/markdown_template.md
DELETED
|
@@ -1,38 +0,0 @@
|
|
| 1 |
-
# Batch Processing Report
|
| 2 |
-
|
| 3 |
-
**Generated:** {{timestamp}}
|
| 4 |
-
**Batch Name:** {{batch_name}}
|
| 5 |
-
|
| 6 |
-
## Processing Summary
|
| 7 |
-
|
| 8 |
-
| Metric | Value |
|
| 9 |
-
|--------|-------|
|
| 10 |
-
| Total Files | {{total_files}} |
|
| 11 |
-
| Successfully Processed | {{successful_files}} |
|
| 12 |
-
| Failed | {{failed_files}} |
|
| 13 |
-
| Success Rate | {{success_rate}}% |
|
| 14 |
-
| Total Processing Time | {{total_time}} seconds |
|
| 15 |
-
| Average Time per File | {{avg_processing_time}} seconds |
|
| 16 |
-
| Throughput | {{throughput}} files/second |
|
| 17 |
-
|
| 18 |
-
## Quality Metrics
|
| 19 |
-
|
| 20 |
-
- **Average SNR:** {{avg_snr}} dB
|
| 21 |
-
- **Average Dynamic Range:** {{avg_dynamic_range}} dB
|
| 22 |
-
- **Files with Quality Issues:** {{files_with_issues}}
|
| 23 |
-
|
| 24 |
-
## Processing Details
|
| 25 |
-
|
| 26 |
-
{{processing_details}}
|
| 27 |
-
|
| 28 |
-
## Error Summary
|
| 29 |
-
|
| 30 |
-
{{error_summary}}
|
| 31 |
-
|
| 32 |
-
## Recommendations
|
| 33 |
-
|
| 34 |
-
{{recommendations}}
|
| 35 |
-
|
| 36 |
-
---
|
| 37 |
-
|
| 38 |
-
*Report generated by Audio Batch Processing System*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test_basic.py
DELETED
|
@@ -1,546 +0,0 @@
|
|
| 1 |
-
"""
|
| 2 |
-
Audio AI Projects - Advanced Audio Processing System
|
| 3 |
-
Copyright (c) 2025 Antonino Mainenti (ninuxi)
|
| 4 |
-
Licensed under MIT License - see LICENSE file
|
| 5 |
-
GitHub: https://github.com/ninuxi/audio-ai-projects
|
| 6 |
-
"""
|
| 7 |
-
k#!/usr/bin/env python3
|
| 8 |
-
"""
|
| 9 |
-
TEST SUITE COMPLETO WEEK 2 - Batch Processor
|
| 10 |
-
Testa tutto il sistema con file audio reali e genera report dettagliati
|
| 11 |
-
"""
|
| 12 |
-
|
| 13 |
-
import os
|
| 14 |
-
import sys
|
| 15 |
-
import tempfile
|
| 16 |
-
import shutil
|
| 17 |
-
import numpy as np
|
| 18 |
-
import soundfile as sf
|
| 19 |
-
import librosa
|
| 20 |
-
from pathlib import Path
|
| 21 |
-
import json
|
| 22 |
-
import time
|
| 23 |
-
import matplotlib.pyplot as plt
|
| 24 |
-
|
| 25 |
-
# Importa tutti i moduli
|
| 26 |
-
from processors.audio_normalizer import AudioNormalizer
|
| 27 |
-
from processors.noise_reducer import NoiseReducer
|
| 28 |
-
from processors.format_converter import FormatConverter
|
| 29 |
-
from processors.metadata_extractor import MetadataExtractor
|
| 30 |
-
from processors.batch_validator import BatchValidator
|
| 31 |
-
from reports.batch_report_generator import BatchReportGenerator
|
| 32 |
-
from reports.quality_analyzer import QualityAnalyzer
|
| 33 |
-
from reports.processing_stats import ProcessingStats
|
| 34 |
-
|
| 35 |
-
class CompleteTestSuite:
|
| 36 |
-
"""Test Suite Completo per Week 2"""
|
| 37 |
-
|
| 38 |
-
def __init__(self):
|
| 39 |
-
self.test_dir = Path("test_results")
|
| 40 |
-
self.test_audio_dir = self.test_dir / "audio_files"
|
| 41 |
-
self.output_dir = self.test_dir / "processed"
|
| 42 |
-
self.reports_dir = self.test_dir / "reports"
|
| 43 |
-
|
| 44 |
-
# Risultati dei test
|
| 45 |
-
self.results = {
|
| 46 |
-
'setup': False,
|
| 47 |
-
'audio_generation': False,
|
| 48 |
-
'processors': {},
|
| 49 |
-
'reports': {},
|
| 50 |
-
'integration': False,
|
| 51 |
-
'performance': {},
|
| 52 |
-
'overall_score': 0
|
| 53 |
-
}
|
| 54 |
-
|
| 55 |
-
self.test_files = []
|
| 56 |
-
|
| 57 |
-
def setup_test_environment(self):
|
| 58 |
-
"""Prepara l'ambiente di test"""
|
| 59 |
-
print("🔧 SETUP AMBIENTE DI TEST")
|
| 60 |
-
print("=" * 50)
|
| 61 |
-
|
| 62 |
-
try:
|
| 63 |
-
# Crea directories
|
| 64 |
-
for directory in [self.test_dir, self.test_audio_dir, self.output_dir, self.reports_dir]:
|
| 65 |
-
directory.mkdir(parents=True, exist_ok=True)
|
| 66 |
-
|
| 67 |
-
print(f"✅ Directories create: {self.test_dir}")
|
| 68 |
-
self.results['setup'] = True
|
| 69 |
-
|
| 70 |
-
except Exception as e:
|
| 71 |
-
print(f"❌ Errore setup: {e}")
|
| 72 |
-
self.results['setup'] = False
|
| 73 |
-
|
| 74 |
-
def generate_test_audio_files(self):
|
| 75 |
-
"""Genera diversi tipi di file audio per il testing"""
|
| 76 |
-
print("\n🎵 GENERAZIONE FILE AUDIO DI TEST")
|
| 77 |
-
print("=" * 50)
|
| 78 |
-
|
| 79 |
-
try:
|
| 80 |
-
sample_rate = 44100
|
| 81 |
-
duration = 3 # 3 secondi
|
| 82 |
-
t = np.linspace(0, duration, int(sample_rate * duration))
|
| 83 |
-
|
| 84 |
-
# 1. Audio normale - tono puro 440Hz
|
| 85 |
-
print("📁 Creando audio normale...")
|
| 86 |
-
audio_normal = 0.5 * np.sin(2 * np.pi * 440 * t)
|
| 87 |
-
normal_file = self.test_audio_dir / "01_normal_tone.wav"
|
| 88 |
-
sf.write(str(normal_file), audio_normal, sample_rate)
|
| 89 |
-
self.test_files.append(str(normal_file))
|
| 90 |
-
|
| 91 |
-
# 2. Audio con rumore
|
| 92 |
-
print("📁 Creando audio con rumore...")
|
| 93 |
-
noise = np.random.normal(0, 0.15, len(audio_normal))
|
| 94 |
-
audio_noisy = audio_normal + noise
|
| 95 |
-
noisy_file = self.test_audio_dir / "02_noisy_audio.wav"
|
| 96 |
-
sf.write(str(noisy_file), audio_noisy, sample_rate)
|
| 97 |
-
self.test_files.append(str(noisy_file))
|
| 98 |
-
|
| 99 |
-
# 3. Audio con clipping
|
| 100 |
-
print("📁 Creando audio con clipping...")
|
| 101 |
-
audio_clipped = np.clip(audio_normal * 2.5, -1, 1)
|
| 102 |
-
clipped_file = self.test_audio_dir / "03_clipped_audio.wav"
|
| 103 |
-
sf.write(str(clipped_file), audio_clipped, sample_rate)
|
| 104 |
-
self.test_files.append(str(clipped_file))
|
| 105 |
-
|
| 106 |
-
# 4. Audio molto silenzioso
|
| 107 |
-
print("📁 Creando audio silenzioso...")
|
| 108 |
-
audio_quiet = audio_normal * 0.02
|
| 109 |
-
quiet_file = self.test_audio_dir / "04_quiet_audio.wav"
|
| 110 |
-
sf.write(str(quiet_file), audio_quiet, sample_rate)
|
| 111 |
-
self.test_files.append(str(quiet_file))
|
| 112 |
-
|
| 113 |
-
# 5. Audio complesso (mix di frequenze)
|
| 114 |
-
print("📁 Creando audio complesso...")
|
| 115 |
-
freq1 = 440 * np.sin(2 * np.pi * 440 * t)
|
| 116 |
-
freq2 = 0.5 * 880 * np.sin(2 * np.pi * 880 * t)
|
| 117 |
-
freq3 = 0.3 * 220 * np.sin(2 * np.pi * 220 * t)
|
| 118 |
-
audio_complex = 0.3 * (freq1 + freq2 + freq3)
|
| 119 |
-
complex_file = self.test_audio_dir / "05_complex_audio.wav"
|
| 120 |
-
sf.write(str(complex_file), audio_complex, sample_rate)
|
| 121 |
-
self.test_files.append(str(complex_file))
|
| 122 |
-
|
| 123 |
-
# 6. Audio con pause di silenzio
|
| 124 |
-
print("📁 Creando audio con pause...")
|
| 125 |
-
silence = np.zeros(int(sample_rate * 0.5))
|
| 126 |
-
audio_with_pauses = np.concatenate([
|
| 127 |
-
silence, audio_normal[:sample_rate], silence,
|
| 128 |
-
audio_normal[sample_rate:2*sample_rate], silence
|
| 129 |
-
])
|
| 130 |
-
pauses_file = self.test_audio_dir / "06_audio_with_pauses.wav"
|
| 131 |
-
sf.write(str(pauses_file), audio_with_pauses, sample_rate)
|
| 132 |
-
self.test_files.append(str(pauses_file))
|
| 133 |
-
|
| 134 |
-
print(f"✅ Creati {len(self.test_files)} file audio di test")
|
| 135 |
-
self.results['audio_generation'] = True
|
| 136 |
-
|
| 137 |
-
except Exception as e:
|
| 138 |
-
print(f"❌ Errore generazione audio: {e}")
|
| 139 |
-
self.results['audio_generation'] = False
|
| 140 |
-
|
| 141 |
-
def test_processors(self):
|
| 142 |
-
"""Test completo di tutti i processors"""
|
| 143 |
-
print("\n🧪 TEST PROCESSORS")
|
| 144 |
-
print("=" * 50)
|
| 145 |
-
|
| 146 |
-
if not self.test_files:
|
| 147 |
-
print("❌ Nessun file audio disponibile")
|
| 148 |
-
return
|
| 149 |
-
|
| 150 |
-
# Test AudioNormalizer
|
| 151 |
-
print("\n📊 Test AudioNormalizer...")
|
| 152 |
-
try:
|
| 153 |
-
normalizer = AudioNormalizer()
|
| 154 |
-
successes = 0
|
| 155 |
-
|
| 156 |
-
for test_file in self.test_files:
|
| 157 |
-
output_file = self.output_dir / f"normalized_{Path(test_file).name}"
|
| 158 |
-
if normalizer.normalize_audio(test_file, str(output_file)):
|
| 159 |
-
successes += 1
|
| 160 |
-
|
| 161 |
-
success_rate = (successes / len(self.test_files)) * 100
|
| 162 |
-
self.results['processors']['AudioNormalizer'] = {
|
| 163 |
-
'success_rate': success_rate,
|
| 164 |
-
'status': '✅ PASS' if success_rate >= 80 else '⚠️ PARTIAL' if success_rate >= 50 else '❌ FAIL'
|
| 165 |
-
}
|
| 166 |
-
print(f" Tasso successo: {success_rate:.0f}%")
|
| 167 |
-
|
| 168 |
-
except Exception as e:
|
| 169 |
-
self.results['processors']['AudioNormalizer'] = {'status': f'❌ ERROR: {e}', 'success_rate': 0}
|
| 170 |
-
|
| 171 |
-
# Test NoiseReducer
|
| 172 |
-
print("\n🔇 Test NoiseReducer...")
|
| 173 |
-
try:
|
| 174 |
-
noise_reducer = NoiseReducer()
|
| 175 |
-
successes = 0
|
| 176 |
-
|
| 177 |
-
for test_file in self.test_files[:3]: # Test sui primi 3 file
|
| 178 |
-
output_file = self.output_dir / f"denoised_{Path(test_file).name}"
|
| 179 |
-
if noise_reducer.reduce_noise(test_file, str(output_file)):
|
| 180 |
-
successes += 1
|
| 181 |
-
|
| 182 |
-
success_rate = (successes / 3) * 100
|
| 183 |
-
self.results['processors']['NoiseReducer'] = {
|
| 184 |
-
'success_rate': success_rate,
|
| 185 |
-
'status': '✅ PASS' if success_rate >= 80 else '⚠️ PARTIAL' if success_rate >= 50 else '❌ FAIL'
|
| 186 |
-
}
|
| 187 |
-
print(f" Tasso successo: {success_rate:.0f}%")
|
| 188 |
-
|
| 189 |
-
except Exception as e:
|
| 190 |
-
self.results['processors']['NoiseReducer'] = {'status': f'❌ ERROR: {e}', 'success_rate': 0}
|
| 191 |
-
|
| 192 |
-
# Test FormatConverter
|
| 193 |
-
print("\n🔄 Test FormatConverter...")
|
| 194 |
-
try:
|
| 195 |
-
converter = FormatConverter()
|
| 196 |
-
successes = 0
|
| 197 |
-
|
| 198 |
-
for i, test_file in enumerate(self.test_files[:2]):
|
| 199 |
-
formats = ['flac', 'ogg']
|
| 200 |
-
target_format = formats[i % len(formats)]
|
| 201 |
-
output_file = self.output_dir / f"converted_{Path(test_file).stem}.{target_format}"
|
| 202 |
-
|
| 203 |
-
if converter.convert_format(test_file, str(output_file), target_format):
|
| 204 |
-
successes += 1
|
| 205 |
-
|
| 206 |
-
success_rate = (successes / 2) * 100
|
| 207 |
-
self.results['processors']['FormatConverter'] = {
|
| 208 |
-
'success_rate': success_rate,
|
| 209 |
-
'status': '✅ PASS' if success_rate >= 80 else '⚠️ PARTIAL' if success_rate >= 50 else '❌ FAIL'
|
| 210 |
-
}
|
| 211 |
-
print(f" Tasso successo: {success_rate:.0f}%")
|
| 212 |
-
|
| 213 |
-
except Exception as e:
|
| 214 |
-
self.results['processors']['FormatConverter'] = {'status': f'❌ ERROR: {e}', 'success_rate': 0}
|
| 215 |
-
|
| 216 |
-
# Test MetadataExtractor
|
| 217 |
-
print("\n📋 Test MetadataExtractor...")
|
| 218 |
-
try:
|
| 219 |
-
extractor = MetadataExtractor()
|
| 220 |
-
successes = 0
|
| 221 |
-
|
| 222 |
-
for test_file in self.test_files:
|
| 223 |
-
# Prova diversi nomi di metodi possibili
|
| 224 |
-
metadata = None
|
| 225 |
-
methods_to_try = ['extract_audio_metadata', 'extract_metadata', 'get_metadata']
|
| 226 |
-
|
| 227 |
-
for method_name in methods_to_try:
|
| 228 |
-
if hasattr(extractor, method_name):
|
| 229 |
-
method = getattr(extractor, method_name)
|
| 230 |
-
try:
|
| 231 |
-
metadata = method(test_file)
|
| 232 |
-
break
|
| 233 |
-
except:
|
| 234 |
-
continue
|
| 235 |
-
|
| 236 |
-
if metadata and isinstance(metadata, dict) and len(metadata) > 0:
|
| 237 |
-
successes += 1
|
| 238 |
-
|
| 239 |
-
success_rate = (successes / len(self.test_files)) * 100
|
| 240 |
-
self.results['processors']['MetadataExtractor'] = {
|
| 241 |
-
'success_rate': success_rate,
|
| 242 |
-
'status': '✅ PASS' if success_rate >= 80 else '⚠️ PARTIAL' if success_rate >= 50 else '❌ FAIL'
|
| 243 |
-
}
|
| 244 |
-
print(f" Tasso successo: {success_rate:.0f}%")
|
| 245 |
-
|
| 246 |
-
except Exception as e:
|
| 247 |
-
self.results['processors']['MetadataExtractor'] = {'status': f'❌ ERROR: {e}', 'success_rate': 0}
|
| 248 |
-
|
| 249 |
-
# Test BatchValidator
|
| 250 |
-
print("\n✔️ Test BatchValidator...")
|
| 251 |
-
try:
|
| 252 |
-
validator = BatchValidator()
|
| 253 |
-
successes = 0
|
| 254 |
-
|
| 255 |
-
for test_file in self.test_files:
|
| 256 |
-
validation = validator.validate_audio_file(test_file)
|
| 257 |
-
if validation and 'is_valid' in validation:
|
| 258 |
-
successes += 1
|
| 259 |
-
|
| 260 |
-
success_rate = (successes / len(self.test_files)) * 100
|
| 261 |
-
self.results['processors']['BatchValidator'] = {
|
| 262 |
-
'success_rate': success_rate,
|
| 263 |
-
'status': '✅ PASS' if success_rate >= 80 else '⚠️ PARTIAL' if success_rate >= 50 else '❌ FAIL'
|
| 264 |
-
}
|
| 265 |
-
print(f" Tasso successo: {success_rate:.0f}%")
|
| 266 |
-
|
| 267 |
-
except Exception as e:
|
| 268 |
-
self.results['processors']['BatchValidator'] = {'status': f'❌ ERROR: {e}', 'success_rate': 0}
|
| 269 |
-
|
| 270 |
-
def test_reports_modules(self):
|
| 271 |
-
"""Test dei moduli di reporting"""
|
| 272 |
-
print("\n📊 TEST REPORTS")
|
| 273 |
-
print("=" * 50)
|
| 274 |
-
|
| 275 |
-
# Test QualityAnalyzer
|
| 276 |
-
print("\n📈 Test QualityAnalyzer...")
|
| 277 |
-
try:
|
| 278 |
-
analyzer = QualityAnalyzer()
|
| 279 |
-
successes = 0
|
| 280 |
-
|
| 281 |
-
for test_file in self.test_files[:3]:
|
| 282 |
-
quality = analyzer.analyze_audio_quality(test_file)
|
| 283 |
-
if quality and 'quality_score' in quality and 'snr' in quality:
|
| 284 |
-
successes += 1
|
| 285 |
-
|
| 286 |
-
success_rate = (successes / 3) * 100
|
| 287 |
-
self.results['reports']['QualityAnalyzer'] = {
|
| 288 |
-
'success_rate': success_rate,
|
| 289 |
-
'status': '✅ PASS' if success_rate >= 80 else '⚠️ PARTIAL' if success_rate >= 50 else '❌ FAIL'
|
| 290 |
-
}
|
| 291 |
-
print(f" Tasso successo: {success_rate:.0f}%")
|
| 292 |
-
|
| 293 |
-
except Exception as e:
|
| 294 |
-
self.results['reports']['QualityAnalyzer'] = {'status': f'❌ ERROR: {e}', 'success_rate': 0}
|
| 295 |
-
|
| 296 |
-
# Test ProcessingStats
|
| 297 |
-
print("\n📊 Test ProcessingStats...")
|
| 298 |
-
try:
|
| 299 |
-
stats = ProcessingStats()
|
| 300 |
-
|
| 301 |
-
# Simula batch processing
|
| 302 |
-
stats.start_batch("test_batch", len(self.test_files))
|
| 303 |
-
|
| 304 |
-
for i, test_file in enumerate(self.test_files):
|
| 305 |
-
processing_time = 0.1 + (i * 0.02)
|
| 306 |
-
success = i < len(self.test_files) - 1 # Simula un fallimento
|
| 307 |
-
error = None if success else "Simulated error"
|
| 308 |
-
|
| 309 |
-
stats.record_file_processing(test_file, success, processing_time, error)
|
| 310 |
-
|
| 311 |
-
batch_results = stats.finish_batch()
|
| 312 |
-
|
| 313 |
-
if batch_results and 'success_rate' in batch_results and 'throughput' in batch_results:
|
| 314 |
-
self.results['reports']['ProcessingStats'] = {
|
| 315 |
-
'success_rate': 100,
|
| 316 |
-
'status': '✅ PASS'
|
| 317 |
-
}
|
| 318 |
-
else:
|
| 319 |
-
self.results['reports']['ProcessingStats'] = {
|
| 320 |
-
'success_rate': 0,
|
| 321 |
-
'status': '❌ FAIL'
|
| 322 |
-
}
|
| 323 |
-
print(f" Batch results generati correttamente")
|
| 324 |
-
|
| 325 |
-
except Exception as e:
|
| 326 |
-
self.results['reports']['ProcessingStats'] = {'status': f'❌ ERROR: {e}', 'success_rate': 0}
|
| 327 |
-
|
| 328 |
-
# Test BatchReportGenerator
|
| 329 |
-
print("\n📝 Test BatchReportGenerator...")
|
| 330 |
-
try:
|
| 331 |
-
generator = BatchReportGenerator(str(self.reports_dir))
|
| 332 |
-
|
| 333 |
-
# Crea dati di test
|
| 334 |
-
test_results = {
|
| 335 |
-
'summary': {
|
| 336 |
-
'total_files': len(self.test_files),
|
| 337 |
-
'successful': len(self.test_files) - 1,
|
| 338 |
-
'failed': 1,
|
| 339 |
-
'success_rate': ((len(self.test_files) - 1) / len(self.test_files)) * 100,
|
| 340 |
-
'total_time': 5.2
|
| 341 |
-
},
|
| 342 |
-
'detailed_results': [
|
| 343 |
-
{
|
| 344 |
-
'file': test_file,
|
| 345 |
-
'status': 'success' if i < len(self.test_files) - 1 else 'failed',
|
| 346 |
-
'time': 0.5 + (i * 0.1),
|
| 347 |
-
'errors': [] if i < len(self.test_files) - 1 else ['Test error']
|
| 348 |
-
}
|
| 349 |
-
for i, test_file in enumerate(self.test_files)
|
| 350 |
-
]
|
| 351 |
-
}
|
| 352 |
-
|
| 353 |
-
report_path = generator.generate_processing_report(test_results)
|
| 354 |
-
|
| 355 |
-
if Path(report_path).exists():
|
| 356 |
-
self.results['reports']['BatchReportGenerator'] = {
|
| 357 |
-
'success_rate': 100,
|
| 358 |
-
'status': '✅ PASS'
|
| 359 |
-
}
|
| 360 |
-
print(f" Report generato: {report_path}")
|
| 361 |
-
else:
|
| 362 |
-
self.results['reports']['BatchReportGenerator'] = {
|
| 363 |
-
'success_rate': 0,
|
| 364 |
-
'status': '❌ FAIL'
|
| 365 |
-
}
|
| 366 |
-
|
| 367 |
-
except Exception as e:
|
| 368 |
-
self.results['reports']['BatchReportGenerator'] = {'status': f'❌ ERROR: {e}', 'success_rate': 0}
|
| 369 |
-
|
| 370 |
-
def test_integration_workflow(self):
|
| 371 |
-
"""Test del workflow completo integrato"""
|
| 372 |
-
print("\n🔗 TEST INTEGRAZIONE WORKFLOW")
|
| 373 |
-
print("=" * 50)
|
| 374 |
-
|
| 375 |
-
try:
|
| 376 |
-
# 1. Validazione batch
|
| 377 |
-
print("1️⃣ Validazione batch...")
|
| 378 |
-
validator = BatchValidator()
|
| 379 |
-
validation_report = self.reports_dir / "validation_batch.json"
|
| 380 |
-
|
| 381 |
-
validation_summary = validator.validate_batch(
|
| 382 |
-
str(self.test_audio_dir),
|
| 383 |
-
str(validation_report)
|
| 384 |
-
)
|
| 385 |
-
|
| 386 |
-
# 2. Analisi qualità batch
|
| 387 |
-
print("2️⃣ Analisi qualità batch...")
|
| 388 |
-
analyzer = QualityAnalyzer()
|
| 389 |
-
quality_report = self.reports_dir / "quality_batch.json"
|
| 390 |
-
|
| 391 |
-
quality_summary = analyzer.batch_quality_analysis(
|
| 392 |
-
str(self.test_audio_dir),
|
| 393 |
-
str(quality_report)
|
| 394 |
-
)
|
| 395 |
-
|
| 396 |
-
# 3. Processing con statistiche
|
| 397 |
-
print("3️⃣ Processing con statistiche...")
|
| 398 |
-
stats = ProcessingStats()
|
| 399 |
-
stats.start_batch("integration_test", len(self.test_files))
|
| 400 |
-
|
| 401 |
-
normalizer = AudioNormalizer()
|
| 402 |
-
processed_files = 0
|
| 403 |
-
|
| 404 |
-
for test_file in self.test_files:
|
| 405 |
-
start_time = time.time()
|
| 406 |
-
output_file = self.output_dir / f"integration_{Path(test_file).name}"
|
| 407 |
-
|
| 408 |
-
success = normalizer.normalize_audio(test_file, str(output_file))
|
| 409 |
-
processing_time = time.time() - start_time
|
| 410 |
-
|
| 411 |
-
stats.record_file_processing(test_file, success, processing_time)
|
| 412 |
-
if success:
|
| 413 |
-
processed_files += 1
|
| 414 |
-
|
| 415 |
-
batch_results = stats.finish_batch()
|
| 416 |
-
|
| 417 |
-
# 4. Report finale
|
| 418 |
-
print("4️⃣ Generazione report finale...")
|
| 419 |
-
generator = BatchReportGenerator(str(self.reports_dir))
|
| 420 |
-
final_report = generator.generate_processing_report(batch_results)
|
| 421 |
-
|
| 422 |
-
# Verifica risultati
|
| 423 |
-
reports_exist = [
|
| 424 |
-
validation_report.exists(),
|
| 425 |
-
quality_report.exists(),
|
| 426 |
-
Path(final_report).exists()
|
| 427 |
-
]
|
| 428 |
-
|
| 429 |
-
integration_score = (
|
| 430 |
-
(processed_files / len(self.test_files)) * 0.4 + # 40% processing success
|
| 431 |
-
(sum(reports_exist) / len(reports_exist)) * 0.6 # 60% reports generation
|
| 432 |
-
) * 100
|
| 433 |
-
|
| 434 |
-
self.results['integration'] = integration_score >= 70
|
| 435 |
-
self.results['performance']['integration_score'] = integration_score
|
| 436 |
-
|
| 437 |
-
print(f"✅ Workflow integrato completato (Score: {integration_score:.0f}%)")
|
| 438 |
-
|
| 439 |
-
except Exception as e:
|
| 440 |
-
print(f"❌ Errore integrazione: {e}")
|
| 441 |
-
self.results['integration'] = False
|
| 442 |
-
self.results['performance']['integration_score'] = 0
|
| 443 |
-
|
| 444 |
-
def generate_final_report(self):
|
| 445 |
-
"""Genera il report finale completo"""
|
| 446 |
-
print("\n📋 GENERAZIONE REPORT FINALE")
|
| 447 |
-
print("=" * 50)
|
| 448 |
-
|
| 449 |
-
# Calcola score complessivo
|
| 450 |
-
all_scores = []
|
| 451 |
-
|
| 452 |
-
# Score processors
|
| 453 |
-
for result in self.results['processors'].values():
|
| 454 |
-
if isinstance(result, dict) and 'success_rate' in result:
|
| 455 |
-
all_scores.append(result['success_rate'])
|
| 456 |
-
|
| 457 |
-
# Score reports
|
| 458 |
-
for result in self.results['reports'].values():
|
| 459 |
-
if isinstance(result, dict) and 'success_rate' in result:
|
| 460 |
-
all_scores.append(result['success_rate'])
|
| 461 |
-
|
| 462 |
-
# Score integrazione
|
| 463 |
-
if 'integration_score' in self.results['performance']:
|
| 464 |
-
all_scores.append(self.results['performance']['integration_score'])
|
| 465 |
-
|
| 466 |
-
overall_score = sum(all_scores) / len(all_scores) if all_scores else 0
|
| 467 |
-
self.results['overall_score'] = overall_score
|
| 468 |
-
|
| 469 |
-
# Salva risultati dettagliati
|
| 470 |
-
results_file = self.reports_dir / "complete_test_results.json"
|
| 471 |
-
with open(results_file, 'w') as f:
|
| 472 |
-
json.dump(self.results, f, indent=2)
|
| 473 |
-
|
| 474 |
-
print(f"📊 Risultati dettagliati salvati in: {results_file}")
|
| 475 |
-
|
| 476 |
-
return overall_score
|
| 477 |
-
|
| 478 |
-
def print_final_summary(self):
|
| 479 |
-
"""Stampa il sommario finale"""
|
| 480 |
-
print("\n" + "=" * 60)
|
| 481 |
-
print("🎯 RISULTATO FINALE TEST SUITE WEEK 2")
|
| 482 |
-
print("=" * 60)
|
| 483 |
-
|
| 484 |
-
print(f"\n📁 Directory test: {self.test_dir}")
|
| 485 |
-
print(f"🎵 File audio creati: {len(self.test_files)}")
|
| 486 |
-
|
| 487 |
-
print(f"\n🧪 PROCESSORS:")
|
| 488 |
-
for name, result in self.results['processors'].items():
|
| 489 |
-
if isinstance(result, dict):
|
| 490 |
-
print(f" {name}: {result['status']}")
|
| 491 |
-
|
| 492 |
-
print(f"\n📊 REPORTS:")
|
| 493 |
-
for name, result in self.results['reports'].items():
|
| 494 |
-
if isinstance(result, dict):
|
| 495 |
-
print(f" {name}: {result['status']}")
|
| 496 |
-
|
| 497 |
-
integration_status = "✅ PASS" if self.results['integration'] else "❌ FAIL"
|
| 498 |
-
print(f"\n🔗 INTEGRAZIONE: {integration_status}")
|
| 499 |
-
|
| 500 |
-
overall_score = self.results['overall_score']
|
| 501 |
-
print(f"\n📈 SCORE COMPLESSIVO: {overall_score:.0f}%")
|
| 502 |
-
|
| 503 |
-
if overall_score >= 90:
|
| 504 |
-
print("🏆 ECCELLENTE! Sistema completamente funzionale")
|
| 505 |
-
elif overall_score >= 75:
|
| 506 |
-
print("✅ BUONO! Sistema funzionale con piccoli problemi")
|
| 507 |
-
elif overall_score >= 60:
|
| 508 |
-
print("⚠️ DISCRETO! Sistema parzialmente funzionale")
|
| 509 |
-
else:
|
| 510 |
-
print("❌ PROBLEMI! Sistema richiede correzioni")
|
| 511 |
-
|
| 512 |
-
print(f"\n💡 Controlla i file in {self.test_dir} per dettagli aggiuntivi")
|
| 513 |
-
|
| 514 |
-
def run_complete_test(self):
|
| 515 |
-
"""Esegue il test suite completo"""
|
| 516 |
-
print("🚀 AVVIO TEST SUITE COMPLETO WEEK 2")
|
| 517 |
-
print("=" * 60)
|
| 518 |
-
|
| 519 |
-
# Esegui tutti i test
|
| 520 |
-
self.setup_test_environment()
|
| 521 |
-
|
| 522 |
-
if self.results['setup']:
|
| 523 |
-
self.generate_test_audio_files()
|
| 524 |
-
|
| 525 |
-
if self.results['audio_generation']:
|
| 526 |
-
self.test_processors()
|
| 527 |
-
self.test_reports_modules()
|
| 528 |
-
self.test_integration_workflow()
|
| 529 |
-
|
| 530 |
-
# Report finale
|
| 531 |
-
overall_score = self.generate_final_report()
|
| 532 |
-
self.print_final_summary()
|
| 533 |
-
|
| 534 |
-
return overall_score >= 60
|
| 535 |
-
|
| 536 |
-
return False
|
| 537 |
-
|
| 538 |
-
|
| 539 |
-
if __name__ == "__main__":
|
| 540 |
-
test_suite = CompleteTestSuite()
|
| 541 |
-
success = test_suite.run_complete_test()
|
| 542 |
-
|
| 543 |
-
if success:
|
| 544 |
-
print("\n🎉 TEST SUITE COMPLETATO CON SUCCESSO!")
|
| 545 |
-
else:
|
| 546 |
-
print("\n⚠️ TEST SUITE COMPLETATO CON PROBLEMI!")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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T License - see LICENSE file
|
| 5 |
-
GitHub: https://github.com/ninuxi/audio-ai-projects
|
| 6 |
-
"""
|
| 7 |
-
#!/usr/bin/env python3
|
| 8 |
-
"""
|
| 9 |
-
TEST SUITE COMPLETO WEEK 2 - Batch Processor
|
| 10 |
-
Testa tutto il sistema con file audio reali e genera report dettagliati
|
| 11 |
-
"""
|
| 12 |
-
|
| 13 |
-
import os
|
| 14 |
-
import sys
|
| 15 |
-
import tempfile
|
| 16 |
-
import shutil
|
| 17 |
-
import numpy as np
|
| 18 |
-
import soundfile as sf
|
| 19 |
-
import librosa
|
| 20 |
-
from pathlib import Path
|
| 21 |
-
import json
|
| 22 |
-
import time
|
| 23 |
-
import matplotlib.pyplot as plt
|
| 24 |
-
|
| 25 |
-
# Importa tutti i moduli
|
| 26 |
-
from processors.audio_normalizer import AudioNormalizer
|
| 27 |
-
from processors.noise_reducer import NoiseReducer
|
| 28 |
-
from processors.format_converter import FormatConverter
|
| 29 |
-
from processors.metadata_extractor import MetadataExtractor
|
| 30 |
-
from processors.batch_validator import BatchValidator
|
| 31 |
-
from reports.batch_report_generator import BatchReportGenerator
|
| 32 |
-
from reports.quality_analyzer import QualityAnalyzer
|
| 33 |
-
from reports.processing_stats import ProcessingStats
|
| 34 |
-
|
| 35 |
-
class CompleteTestSuite:
|
| 36 |
-
"""Test Suite Completo per Week 2"""
|
| 37 |
-
|
| 38 |
-
def __init__(self):
|
| 39 |
-
self.test_dir = Path("test_results")
|
| 40 |
-
self.test_audio_dir = self.test_dir / "audio_files"
|
| 41 |
-
self.output_dir = self.test_dir / "processed"
|
| 42 |
-
self.reports_dir = self.test_dir / "reports"
|
| 43 |
-
|
| 44 |
-
# Risultati dei test
|
| 45 |
-
self.results = {
|
| 46 |
-
'setup': False,
|
| 47 |
-
'audio_generation': False,
|
| 48 |
-
'processors': {},
|
| 49 |
-
'reports': {},
|
| 50 |
-
'integration': False,
|
| 51 |
-
'performance': {},
|
| 52 |
-
'overall_score': 0
|
| 53 |
-
}
|
| 54 |
-
|
| 55 |
-
self.test_files = []
|
| 56 |
-
|
| 57 |
-
def setup_test_environment(self):
|
| 58 |
-
"""Prepara l'ambiente di test"""
|
| 59 |
-
print("🔧 SETUP AMBIENTE DI TEST")
|
| 60 |
-
print("=" * 50)
|
| 61 |
-
|
| 62 |
-
try:
|
| 63 |
-
# Crea directories
|
| 64 |
-
for directory in [self.test_dir, self.test_audio_dir, self.output_dir, self.reports_dir]:
|
| 65 |
-
directory.mkdir(parents=True, exist_ok=True)
|
| 66 |
-
|
| 67 |
-
print(f"✅ Directories create: {self.test_dir}")
|
| 68 |
-
self.results['setup'] = True
|
| 69 |
-
|
| 70 |
-
except Exception as e:
|
| 71 |
-
print(f"❌ Errore setup: {e}")
|
| 72 |
-
self.results['setup'] = False
|
| 73 |
-
|
| 74 |
-
def generate_test_audio_files(self):
|
| 75 |
-
"""Genera diversi tipi di file audio per il testing"""
|
| 76 |
-
print("\n🎵 GENERAZIONE FILE AUDIO DI TEST")
|
| 77 |
-
print("=" * 50)
|
| 78 |
-
|
| 79 |
-
try:
|
| 80 |
-
sample_rate = 44100
|
| 81 |
-
duration = 3 # 3 secondi
|
| 82 |
-
t = np.linspace(0, duration, int(sample_rate * duration))
|
| 83 |
-
|
| 84 |
-
# 1. Audio normale - tono puro 440Hz
|
| 85 |
-
print("📁 Creando audio normale...")
|
| 86 |
-
audio_normal = 0.5 * np.sin(2 * np.pi * 440 * t)
|
| 87 |
-
normal_file = self.test_audio_dir / "01_normal_tone.wav"
|
| 88 |
-
sf.write(str(normal_file), audio_normal, sample_rate)
|
| 89 |
-
self.test_files.append(str(normal_file))
|
| 90 |
-
|
| 91 |
-
# 2. Audio con rumore
|
| 92 |
-
print("📁 Creando audio con rumore...")
|
| 93 |
-
noise = np.random.normal(0, 0.15, len(audio_normal))
|
| 94 |
-
audio_noisy = audio_normal + noise
|
| 95 |
-
noisy_file = self.test_audio_dir / "02_noisy_audio.wav"
|
| 96 |
-
sf.write(str(noisy_file), audio_noisy, sample_rate)
|
| 97 |
-
self.test_files.append(str(noisy_file))
|
| 98 |
-
|
| 99 |
-
# 3. Audio con clipping
|
| 100 |
-
print("📁 Creando audio con clipping...")
|
| 101 |
-
audio_clipped = np.clip(audio_normal * 2.5, -1, 1)
|
| 102 |
-
clipped_file = self.test_audio_dir / "03_clipped_audio.wav"
|
| 103 |
-
sf.write(str(clipped_file), audio_clipped, sample_rate)
|
| 104 |
-
self.test_files.append(str(clipped_file))
|
| 105 |
-
|
| 106 |
-
# 4. Audio molto silenzioso
|
| 107 |
-
print("📁 Creando audio silenzioso...")
|
| 108 |
-
audio_quiet = audio_normal * 0.02
|
| 109 |
-
quiet_file = self.test_audio_dir / "04_quiet_audio.wav"
|
| 110 |
-
sf.write(str(quiet_file), audio_quiet, sample_rate)
|
| 111 |
-
self.test_files.append(str(quiet_file))
|
| 112 |
-
|
| 113 |
-
# 5. Audio complesso (mix di frequenze)
|
| 114 |
-
print("📁 Creando audio complesso...")
|
| 115 |
-
freq1 = 440 * np.sin(2 * np.pi * 440 * t)
|
| 116 |
-
freq2 = 0.5 * 880 * np.sin(2 * np.pi * 880 * t)
|
| 117 |
-
freq3 = 0.3 * 220 * np.sin(2 * np.pi * 220 * t)
|
| 118 |
-
audio_complex = 0.3 * (freq1 + freq2 + freq3)
|
| 119 |
-
complex_file = self.test_audio_dir / "05_complex_audio.wav"
|
| 120 |
-
sf.write(str(complex_file), audio_complex, sample_rate)
|
| 121 |
-
self.test_files.append(str(complex_file))
|
| 122 |
-
|
| 123 |
-
# 6. Audio con pause di silenzio
|
| 124 |
-
print("📁 Creando audio con pause...")
|
| 125 |
-
silence = np.zeros(int(sample_rate * 0.5))
|
| 126 |
-
audio_with_pauses = np.concatenate([
|
| 127 |
-
silence, audio_normal[:sample_rate], silence,
|
| 128 |
-
audio_normal[sample_rate:2*sample_rate], silence
|
| 129 |
-
])
|
| 130 |
-
pauses_file = self.test_audio_dir / "06_audio_with_pauses.wav"
|
| 131 |
-
sf.write(str(pauses_file), audio_with_pauses, sample_rate)
|
| 132 |
-
self.test_files.append(str(pauses_file))
|
| 133 |
-
|
| 134 |
-
print(f"✅ Creati {len(self.test_files)} file audio di test")
|
| 135 |
-
self.results['audio_generation'] = True
|
| 136 |
-
|
| 137 |
-
except Exception as e:
|
| 138 |
-
print(f"❌ Errore generazione audio: {e}")
|
| 139 |
-
self.results['audio_generation'] = False
|
| 140 |
-
|
| 141 |
-
def test_processors(self):
|
| 142 |
-
"""Test completo di tutti i processors"""
|
| 143 |
-
print("\n🧪 TEST PROCESSORS")
|
| 144 |
-
print("=" * 50)
|
| 145 |
-
|
| 146 |
-
if not self.test_files:
|
| 147 |
-
print("❌ Nessun file audio disponibile")
|
| 148 |
-
return
|
| 149 |
-
|
| 150 |
-
# Test AudioNormalizer
|
| 151 |
-
print("\n📊 Test AudioNormalizer...")
|
| 152 |
-
try:
|
| 153 |
-
normalizer = AudioNormalizer()
|
| 154 |
-
successes = 0
|
| 155 |
-
|
| 156 |
-
for test_file in self.test_files:
|
| 157 |
-
output_file = self.output_dir / f"normalized_{Path(test_file).name}"
|
| 158 |
-
if normalizer.normalize_audio(test_file, str(output_file)):
|
| 159 |
-
successes += 1
|
| 160 |
-
|
| 161 |
-
success_rate = (successes / len(self.test_files)) * 100
|
| 162 |
-
self.results['processors']['AudioNormalizer'] = {
|
| 163 |
-
'success_rate': success_rate,
|
| 164 |
-
'status': '✅ PASS' if success_rate >= 80 else '⚠️ PARTIAL' if success_rate >= 50 else '❌ FAIL'
|
| 165 |
-
}
|
| 166 |
-
print(f" Tasso successo: {success_rate:.0f}%")
|
| 167 |
-
|
| 168 |
-
except Exception as e:
|
| 169 |
-
self.results['processors']['AudioNormalizer'] = {'status': f'❌ ERROR: {e}', 'success_rate': 0}
|
| 170 |
-
|
| 171 |
-
# Test NoiseReducer
|
| 172 |
-
print("\n🔇 Test NoiseReducer...")
|
| 173 |
-
try:
|
| 174 |
-
noise_reducer = NoiseReducer()
|
| 175 |
-
successes = 0
|
| 176 |
-
|
| 177 |
-
for test_file in self.test_files[:3]: # Test sui primi 3 file
|
| 178 |
-
output_file = self.output_dir / f"denoised_{Path(test_file).name}"
|
| 179 |
-
if noise_reducer.reduce_noise(test_file, str(output_file)):
|
| 180 |
-
successes += 1
|
| 181 |
-
|
| 182 |
-
success_rate = (successes / 3) * 100
|
| 183 |
-
self.results['processors']['NoiseReducer'] = {
|
| 184 |
-
'success_rate': success_rate,
|
| 185 |
-
'status': '✅ PASS' if success_rate >= 80 else '⚠️ PARTIAL' if success_rate >= 50 else '❌ FAIL'
|
| 186 |
-
}
|
| 187 |
-
print(f" Tasso successo: {success_rate:.0f}%")
|
| 188 |
-
|
| 189 |
-
except Exception as e:
|
| 190 |
-
self.results['processors']['NoiseReducer'] = {'status': f'❌ ERROR: {e}', 'success_rate': 0}
|
| 191 |
-
|
| 192 |
-
# Test FormatConverter
|
| 193 |
-
print("\n🔄 Test FormatConverter...")
|
| 194 |
-
try:
|
| 195 |
-
converter = FormatConverter()
|
| 196 |
-
successes = 0
|
| 197 |
-
|
| 198 |
-
for i, test_file in enumerate(self.test_files[:2]):
|
| 199 |
-
formats = ['flac', 'ogg']
|
| 200 |
-
target_format = formats[i % len(formats)]
|
| 201 |
-
output_file = self.output_dir / f"converted_{Path(test_file).stem}.{target_format}"
|
| 202 |
-
|
| 203 |
-
if converter.convert_format(test_file, str(output_file), target_format):
|
| 204 |
-
successes += 1
|
| 205 |
-
|
| 206 |
-
success_rate = (successes / 2) * 100
|
| 207 |
-
self.results['processors']['FormatConverter'] = {
|
| 208 |
-
'success_rate': success_rate,
|
| 209 |
-
'status': '✅ PASS' if success_rate >= 80 else '⚠️ PARTIAL' if success_rate >= 50 else '❌ FAIL'
|
| 210 |
-
}
|
| 211 |
-
print(f" Tasso successo: {success_rate:.0f}%")
|
| 212 |
-
|
| 213 |
-
except Exception as e:
|
| 214 |
-
self.results['processors']['FormatConverter'] = {'status': f'❌ ERROR: {e}', 'success_rate': 0}
|
| 215 |
-
|
| 216 |
-
# Test MetadataExtractor
|
| 217 |
-
print("\n📋 Test MetadataExtractor...")
|
| 218 |
-
try:
|
| 219 |
-
extractor = MetadataExtractor()
|
| 220 |
-
successes = 0
|
| 221 |
-
|
| 222 |
-
for test_file in self.test_files:
|
| 223 |
-
# Prova diversi nomi di metodi possibili
|
| 224 |
-
metadata = None
|
| 225 |
-
methods_to_try = ['extract_audio_metadata', 'extract_metadata', 'get_metadata']
|
| 226 |
-
|
| 227 |
-
for method_name in methods_to_try:
|
| 228 |
-
if hasattr(extractor, method_name):
|
| 229 |
-
method = getattr(extractor, method_name)
|
| 230 |
-
try:
|
| 231 |
-
metadata = method(test_file)
|
| 232 |
-
break
|
| 233 |
-
except:
|
| 234 |
-
continue
|
| 235 |
-
|
| 236 |
-
if metadata and isinstance(metadata, dict) and len(metadata) > 0:
|
| 237 |
-
successes += 1
|
| 238 |
-
|
| 239 |
-
success_rate = (successes / len(self.test_files)) * 100
|
| 240 |
-
self.results['processors']['MetadataExtractor'] = {
|
| 241 |
-
'success_rate': success_rate,
|
| 242 |
-
'status': '✅ PASS' if success_rate >= 80 else '⚠️ PARTIAL' if success_rate >= 50 else '❌ FAIL'
|
| 243 |
-
}
|
| 244 |
-
print(f" Tasso successo: {success_rate:.0f}%")
|
| 245 |
-
|
| 246 |
-
except Exception as e:
|
| 247 |
-
self.results['processors']['MetadataExtractor'] = {'status': f'❌ ERROR: {e}', 'success_rate': 0}
|
| 248 |
-
|
| 249 |
-
# Test BatchValidator
|
| 250 |
-
print("\n✔️ Test BatchValidator...")
|
| 251 |
-
try:
|
| 252 |
-
validator = BatchValidator()
|
| 253 |
-
successes = 0
|
| 254 |
-
|
| 255 |
-
for test_file in self.test_files:
|
| 256 |
-
validation = validator.validate_audio_file(test_file)
|
| 257 |
-
if validation and 'is_valid' in validation:
|
| 258 |
-
successes += 1
|
| 259 |
-
|
| 260 |
-
success_rate = (successes / len(self.test_files)) * 100
|
| 261 |
-
self.results['processors']['BatchValidator'] = {
|
| 262 |
-
'success_rate': success_rate,
|
| 263 |
-
'status': '✅ PASS' if success_rate >= 80 else '⚠️ PARTIAL' if success_rate >= 50 else '❌ FAIL'
|
| 264 |
-
}
|
| 265 |
-
print(f" Tasso successo: {success_rate:.0f}%")
|
| 266 |
-
|
| 267 |
-
except Exception as e:
|
| 268 |
-
self.results['processors']['BatchValidator'] = {'status': f'❌ ERROR: {e}', 'success_rate': 0}
|
| 269 |
-
|
| 270 |
-
def test_reports_modules(self):
|
| 271 |
-
"""Test dei moduli di reporting"""
|
| 272 |
-
print("\n📊 TEST REPORTS")
|
| 273 |
-
print("=" * 50)
|
| 274 |
-
|
| 275 |
-
# Test QualityAnalyzer
|
| 276 |
-
print("\n📈 Test QualityAnalyzer...")
|
| 277 |
-
try:
|
| 278 |
-
analyzer = QualityAnalyzer()
|
| 279 |
-
successes = 0
|
| 280 |
-
|
| 281 |
-
for test_file in self.test_files[:3]:
|
| 282 |
-
quality = analyzer.analyze_audio_quality(test_file)
|
| 283 |
-
if quality and 'quality_score' in quality and 'snr' in quality:
|
| 284 |
-
successes += 1
|
| 285 |
-
|
| 286 |
-
success_rate = (successes / 3) * 100
|
| 287 |
-
self.results['reports']['QualityAnalyzer'] = {
|
| 288 |
-
'success_rate': success_rate,
|
| 289 |
-
'status': '✅ PASS' if success_rate >= 80 else '⚠️ PARTIAL' if success_rate >= 50 else '❌ FAIL'
|
| 290 |
-
}
|
| 291 |
-
print(f" Tasso successo: {success_rate:.0f}%")
|
| 292 |
-
|
| 293 |
-
except Exception as e:
|
| 294 |
-
self.results['reports']['QualityAnalyzer'] = {'status': f'❌ ERROR: {e}', 'success_rate': 0}
|
| 295 |
-
|
| 296 |
-
# Test ProcessingStats
|
| 297 |
-
print("\n📊 Test ProcessingStats...")
|
| 298 |
-
try:
|
| 299 |
-
stats = ProcessingStats()
|
| 300 |
-
|
| 301 |
-
# Simula batch processing
|
| 302 |
-
stats.start_batch("test_batch", len(self.test_files))
|
| 303 |
-
|
| 304 |
-
for i, test_file in enumerate(self.test_files):
|
| 305 |
-
processing_time = 0.1 + (i * 0.02)
|
| 306 |
-
success = i < len(self.test_files) - 1 # Simula un fallimento
|
| 307 |
-
error = None if success else "Simulated error"
|
| 308 |
-
|
| 309 |
-
stats.record_file_processing(test_file, success, processing_time, error)
|
| 310 |
-
|
| 311 |
-
batch_results = stats.finish_batch()
|
| 312 |
-
|
| 313 |
-
if batch_results and 'success_rate' in batch_results and 'throughput' in batch_results:
|
| 314 |
-
self.results['reports']['ProcessingStats'] = {
|
| 315 |
-
'success_rate': 100,
|
| 316 |
-
'status': '✅ PASS'
|
| 317 |
-
}
|
| 318 |
-
else:
|
| 319 |
-
self.results['reports']['ProcessingStats'] = {
|
| 320 |
-
'success_rate': 0,
|
| 321 |
-
'status': '❌ FAIL'
|
| 322 |
-
}
|
| 323 |
-
print(f" Batch results generati correttamente")
|
| 324 |
-
|
| 325 |
-
except Exception as e:
|
| 326 |
-
self.results['reports']['ProcessingStats'] = {'status': f'❌ ERROR: {e}', 'success_rate': 0}
|
| 327 |
-
|
| 328 |
-
# Test BatchReportGenerator
|
| 329 |
-
print("\n📝 Test BatchReportGenerator...")
|
| 330 |
-
try:
|
| 331 |
-
generator = BatchReportGenerator(str(self.reports_dir))
|
| 332 |
-
|
| 333 |
-
# Crea dati di test
|
| 334 |
-
test_results = {
|
| 335 |
-
'summary': {
|
| 336 |
-
'total_files': len(self.test_files),
|
| 337 |
-
'successful': len(self.test_files) - 1,
|
| 338 |
-
'failed': 1,
|
| 339 |
-
'success_rate': ((len(self.test_files) - 1) / len(self.test_files)) * 100,
|
| 340 |
-
'total_time': 5.2
|
| 341 |
-
},
|
| 342 |
-
'detailed_results': [
|
| 343 |
-
{
|
| 344 |
-
'file': test_file,
|
| 345 |
-
'status': 'success' if i < len(self.test_files) - 1 else 'failed',
|
| 346 |
-
'time': 0.5 + (i * 0.1),
|
| 347 |
-
'errors': [] if i < len(self.test_files) - 1 else ['Test error']
|
| 348 |
-
}
|
| 349 |
-
for i, test_file in enumerate(self.test_files)
|
| 350 |
-
]
|
| 351 |
-
}
|
| 352 |
-
|
| 353 |
-
report_path = generator.generate_processing_report(test_results)
|
| 354 |
-
|
| 355 |
-
if Path(report_path).exists():
|
| 356 |
-
self.results['reports']['BatchReportGenerator'] = {
|
| 357 |
-
'success_rate': 100,
|
| 358 |
-
'status': '✅ PASS'
|
| 359 |
-
}
|
| 360 |
-
print(f" Report generato: {report_path}")
|
| 361 |
-
else:
|
| 362 |
-
self.results['reports']['BatchReportGenerator'] = {
|
| 363 |
-
'success_rate': 0,
|
| 364 |
-
'status': '❌ FAIL'
|
| 365 |
-
}
|
| 366 |
-
|
| 367 |
-
except Exception as e:
|
| 368 |
-
self.results['reports']['BatchReportGenerator'] = {'status': f'❌ ERROR: {e}', 'success_rate': 0}
|
| 369 |
-
|
| 370 |
-
def test_integration_workflow(self):
|
| 371 |
-
"""Test del workflow completo integrato"""
|
| 372 |
-
print("\n🔗 TEST INTEGRAZIONE WORKFLOW")
|
| 373 |
-
print("=" * 50)
|
| 374 |
-
|
| 375 |
-
try:
|
| 376 |
-
# 1. Validazione batch
|
| 377 |
-
print("1️⃣ Validazione batch...")
|
| 378 |
-
validator = BatchValidator()
|
| 379 |
-
validation_report = self.reports_dir / "validation_batch.json"
|
| 380 |
-
|
| 381 |
-
validation_summary = validator.validate_batch(
|
| 382 |
-
str(self.test_audio_dir),
|
| 383 |
-
str(validation_report)
|
| 384 |
-
)
|
| 385 |
-
|
| 386 |
-
# 2. Analisi qualità batch
|
| 387 |
-
print("2️⃣ Analisi qualità batch...")
|
| 388 |
-
analyzer = QualityAnalyzer()
|
| 389 |
-
quality_report = self.reports_dir / "quality_batch.json"
|
| 390 |
-
|
| 391 |
-
quality_summary = analyzer.batch_quality_analysis(
|
| 392 |
-
str(self.test_audio_dir),
|
| 393 |
-
str(quality_report)
|
| 394 |
-
)
|
| 395 |
-
|
| 396 |
-
# 3. Processing con statistiche
|
| 397 |
-
print("3️⃣ Processing con statistiche...")
|
| 398 |
-
stats = ProcessingStats()
|
| 399 |
-
stats.start_batch("integration_test", len(self.test_files))
|
| 400 |
-
|
| 401 |
-
normalizer = AudioNormalizer()
|
| 402 |
-
processed_files = 0
|
| 403 |
-
|
| 404 |
-
for test_file in self.test_files:
|
| 405 |
-
start_time = time.time()
|
| 406 |
-
output_file = self.output_dir / f"integration_{Path(test_file).name}"
|
| 407 |
-
|
| 408 |
-
success = normalizer.normalize_audio(test_file, str(output_file))
|
| 409 |
-
processing_time = time.time() - start_time
|
| 410 |
-
|
| 411 |
-
stats.record_file_processing(test_file, success, processing_time)
|
| 412 |
-
if success:
|
| 413 |
-
processed_files += 1
|
| 414 |
-
|
| 415 |
-
batch_results = stats.finish_batch()
|
| 416 |
-
|
| 417 |
-
# 4. Report finale
|
| 418 |
-
print("4️⃣ Generazione report finale...")
|
| 419 |
-
generator = BatchReportGenerator(str(self.reports_dir))
|
| 420 |
-
final_report = generator.generate_processing_report(batch_results)
|
| 421 |
-
|
| 422 |
-
# Verifica risultati
|
| 423 |
-
reports_exist = [
|
| 424 |
-
validation_report.exists(),
|
| 425 |
-
quality_report.exists(),
|
| 426 |
-
Path(final_report).exists()
|
| 427 |
-
]
|
| 428 |
-
|
| 429 |
-
integration_score = (
|
| 430 |
-
(processed_files / len(self.test_files)) * 0.4 + # 40% processing success
|
| 431 |
-
(sum(reports_exist) / len(reports_exist)) * 0.6 # 60% reports generation
|
| 432 |
-
) * 100
|
| 433 |
-
|
| 434 |
-
self.results['integration'] = integration_score >= 70
|
| 435 |
-
self.results['performance']['integration_score'] = integration_score
|
| 436 |
-
|
| 437 |
-
print(f"✅ Workflow integrato completato (Score: {integration_score:.0f}%)")
|
| 438 |
-
|
| 439 |
-
except Exception as e:
|
| 440 |
-
print(f"❌ Errore integrazione: {e}")
|
| 441 |
-
self.results['integration'] = False
|
| 442 |
-
self.results['performance']['integration_score'] = 0
|
| 443 |
-
|
| 444 |
-
def generate_final_report(self):
|
| 445 |
-
"""Genera il report finale completo"""
|
| 446 |
-
print("\n📋 GENERAZIONE REPORT FINALE")
|
| 447 |
-
print("=" * 50)
|
| 448 |
-
|
| 449 |
-
# Calcola score complessivo
|
| 450 |
-
all_scores = []
|
| 451 |
-
|
| 452 |
-
# Score processors
|
| 453 |
-
for result in self.results['processors'].values():
|
| 454 |
-
if isinstance(result, dict) and 'success_rate' in result:
|
| 455 |
-
all_scores.append(result['success_rate'])
|
| 456 |
-
|
| 457 |
-
# Score reports
|
| 458 |
-
for result in self.results['reports'].values():
|
| 459 |
-
if isinstance(result, dict) and 'success_rate' in result:
|
| 460 |
-
all_scores.append(result['success_rate'])
|
| 461 |
-
|
| 462 |
-
# Score integrazione
|
| 463 |
-
if 'integration_score' in self.results['performance']:
|
| 464 |
-
all_scores.append(self.results['performance']['integration_score'])
|
| 465 |
-
|
| 466 |
-
overall_score = sum(all_scores) / len(all_scores) if all_scores else 0
|
| 467 |
-
self.results['overall_score'] = overall_score
|
| 468 |
-
|
| 469 |
-
# Salva risultati dettagliati
|
| 470 |
-
results_file = self.reports_dir / "complete_test_results.json"
|
| 471 |
-
with open(results_file, 'w') as f:
|
| 472 |
-
json.dump(self.results, f, indent=2)
|
| 473 |
-
|
| 474 |
-
print(f"📊 Risultati dettagliati salvati in: {results_file}")
|
| 475 |
-
|
| 476 |
-
return overall_score
|
| 477 |
-
|
| 478 |
-
def print_final_summary(self):
|
| 479 |
-
"""Stampa il sommario finale"""
|
| 480 |
-
print("\n" + "=" * 60)
|
| 481 |
-
print("🎯 RISULTATO FINALE TEST SUITE WEEK 2")
|
| 482 |
-
print("=" * 60)
|
| 483 |
-
|
| 484 |
-
print(f"\n📁 Directory test: {self.test_dir}")
|
| 485 |
-
print(f"🎵 File audio creati: {len(self.test_files)}")
|
| 486 |
-
|
| 487 |
-
print(f"\n🧪 PROCESSORS:")
|
| 488 |
-
for name, result in self.results['processors'].items():
|
| 489 |
-
if isinstance(result, dict):
|
| 490 |
-
print(f" {name}: {result['status']}")
|
| 491 |
-
|
| 492 |
-
print(f"\n📊 REPORTS:")
|
| 493 |
-
for name, result in self.results['reports'].items():
|
| 494 |
-
if isinstance(result, dict):
|
| 495 |
-
print(f" {name}: {result['status']}")
|
| 496 |
-
|
| 497 |
-
integration_status = "✅ PASS" if self.results['integration'] else "❌ FAIL"
|
| 498 |
-
print(f"\n🔗 INTEGRAZIONE: {integration_status}")
|
| 499 |
-
|
| 500 |
-
overall_score = self.results['overall_score']
|
| 501 |
-
print(f"\n📈 SCORE COMPLESSIVO: {overall_score:.0f}%")
|
| 502 |
-
|
| 503 |
-
if overall_score >= 90:
|
| 504 |
-
print("🏆 ECCELLENTE! Sistema completamente funzionale")
|
| 505 |
-
elif overall_score >= 75:
|
| 506 |
-
print("✅ BUONO! Sistema funzionale con piccoli problemi")
|
| 507 |
-
elif overall_score >= 60:
|
| 508 |
-
print("⚠️ DISCRETO! Sistema parzialmente funzionale")
|
| 509 |
-
else:
|
| 510 |
-
print("❌ PROBLEMI! Sistema richiede correzioni")
|
| 511 |
-
|
| 512 |
-
print(f"\n💡 Controlla i file in {self.test_dir} per dettagli aggiuntivi")
|
| 513 |
-
|
| 514 |
-
def run_complete_test(self):
|
| 515 |
-
"""Esegue il test suite completo"""
|
| 516 |
-
print("🚀 AVVIO TEST SUITE COMPLETO WEEK 2")
|
| 517 |
-
print("=" * 60)
|
| 518 |
-
|
| 519 |
-
# Esegui tutti i test
|
| 520 |
-
self.setup_test_environment()
|
| 521 |
-
|
| 522 |
-
if self.results['setup']:
|
| 523 |
-
self.generate_test_audio_files()
|
| 524 |
-
|
| 525 |
-
if self.results['audio_generation']:
|
| 526 |
-
self.test_processors()
|
| 527 |
-
self.test_reports_modules()
|
| 528 |
-
self.test_integration_workflow()
|
| 529 |
-
|
| 530 |
-
# Report finale
|
| 531 |
-
overall_score = self.generate_final_report()
|
| 532 |
-
self.print_final_summary()
|
| 533 |
-
|
| 534 |
-
return overall_score >= 60
|
| 535 |
-
|
| 536 |
-
return False
|
| 537 |
-
|
| 538 |
-
|
| 539 |
-
if __name__ == "__main__":
|
| 540 |
-
test_suite = CompleteTestSuite()
|
| 541 |
-
success = test_suite.run_complete_test()
|
| 542 |
-
|
| 543 |
-
if success:
|
| 544 |
-
print("\n🎉 TEST SUITE COMPLETATO CON SUCCESSO!")
|
| 545 |
-
else:
|
| 546 |
-
print("\n⚠️ TEST SUITE COMPLETATO CON PROBLEMI!")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test_results/audio_files/01_normal_tone.wav
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:a4d30c7f83c25e8f96b8d1d326f5eea0a89a2927ce5d26951e2d8afdf6227686
|
| 3 |
-
size 264644
|
|
|
|
|
|
|
|
|
|
|
|
test_results/audio_files/02_noisy_audio.wav
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:a9f8c3521e474dd1d479af4e2cf6084f7fb01eb7dc7b5bf945cadc64fbe9fea0
|
| 3 |
-
size 264644
|
|
|
|
|
|
|
|
|
|
|
|
test_results/audio_files/03_clipped_audio.wav
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:51274788382ca6d089c72554b745c962dbc9347121e64a0b5d34e3e934adc895
|
| 3 |
-
size 264644
|
|
|
|
|
|
|
|
|
|
|
|
test_results/audio_files/04_quiet_audio.wav
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:a173a5d3908272ef73ea5ec4b3bb05b4a8a40ecca3b1b890aaee436efeb07e3b
|
| 3 |
-
size 264644
|
|
|
|
|
|
|
|
|
|
|
|
test_results/audio_files/05_complex_audio.wav
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:4c5720a4d549f59a241151f27b289b91dfd33a893188f4c5bf47c20c03fe6cc9
|
| 3 |
-
size 264644
|
|
|
|
|
|
|
|
|
|
|
|
test_results/audio_files/06_audio_with_pauses.wav
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:34f25b1bded366bf2c405d49ec058f2b624cc8f584fa17e1b6d2f267294503d1
|
| 3 |
-
size 308744
|
|
|
|
|
|
|
|
|
|
|
|
test_results/processed/converted_01_normal_tone.flac
DELETED
|
Binary file (39 kB)
|
|
|
test_results/processed/converted_02_noisy_audio.ogg
DELETED
|
Binary file (32.6 kB)
|
|
|
test_results/processed/denoised_01_normal_tone.wav
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:e5d60f564aced8bc4682c54a533a14bab4fa0e45e3eb419dc4a4d54d4badf8ad
|
| 3 |
-
size 264644
|
|
|
|
|
|
|
|
|
|
|
|
test_results/processed/denoised_02_noisy_audio.wav
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:9a0bab9093c8695a853c59fd30fc740eebcd409cce70bf0fdbba72e03eb6208c
|
| 3 |
-
size 264644
|
|
|
|
|
|
|
|
|
|
|
|
test_results/processed/denoised_03_clipped_audio.wav
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:6f941070ec5c5eee23005ee2d0d9517f5834f8bd94b4036363a66fa35a3109cb
|
| 3 |
-
size 264644
|
|
|
|
|
|
|
|
|
|
|
|
test_results/processed/integration_01_normal_tone.wav
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:09e317a1d2ccf86a1e7a86e332ad704b72513ee71517bde85be820abcd67c09e
|
| 3 |
-
size 264644
|
|
|
|
|
|
|
|
|
|
|
|
test_results/processed/integration_02_noisy_audio.wav
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:45695585e0a42a50f62e8c672d927f1e8bcc978873e4ad4fcb41652108e4aef9
|
| 3 |
-
size 264644
|
|
|
|
|
|
|
|
|
|
|
|
test_results/processed/integration_03_clipped_audio.wav
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:f0339369c78b0c2b667c44d2a9174ec347cae8ddb93d633037471cd143ec407c
|
| 3 |
-
size 264644
|
|
|
|
|
|
|
|
|
|
|
|
test_results/processed/integration_04_quiet_audio.wav
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:954f65e61462723a6d84489394976c5d495c474a2969513312e8a1b8873e04c6
|
| 3 |
-
size 264644
|
|
|
|
|
|
|
|
|
|
|
|
test_results/processed/integration_05_complex_audio.wav
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:23f24a004e3f9aeab44cc4ff42ffedb5b1f617c58e898dba4465b9c935ad453f
|
| 3 |
-
size 264644
|
|
|
|
|
|
|
|
|
|
|
|