Upload File Teknis Skripsi
This commit is contained in:
parent
fa29714638
commit
65877b69ad
|
@ -0,0 +1,392 @@
|
||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"**LIBARRY**"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 9,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import librosa\n",
|
||||||
|
"import numpy as np\n",
|
||||||
|
"import os\n",
|
||||||
|
"import joblib\n",
|
||||||
|
"import pandas as pd"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"**PATH DATASET**"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 10,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# Path dataset hasil preprocessing\n",
|
||||||
|
"DATASET_PATH = \"preprocessing_data_v2\"\n",
|
||||||
|
"OUTPUT_FOLDER = \"E:\\! KULIAHHH\\Ivano Kuliah\\!SEMESTER 8\\!SKRIPSI\\Data Suara\\!REVISI\\hasil_ekstrak_mfcc_v2\"\n",
|
||||||
|
"\n",
|
||||||
|
"# Buat folder output jika belum ada\n",
|
||||||
|
"os.makedirs(OUTPUT_FOLDER, exist_ok=True)\n",
|
||||||
|
"\n",
|
||||||
|
"# Path penyimpanan file hasil ekstraksi\n",
|
||||||
|
"OUTPUT_FEATURES = os.path.join(OUTPUT_FOLDER, \"X_train.npy\")\n",
|
||||||
|
"OUTPUT_LABELS = os.path.join(OUTPUT_FOLDER, \"y_train.npy\")"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"**PARAMETER MFCC**"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 11,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# Parameter MFCC\n",
|
||||||
|
"SAMPLE_RATE = 48000\n",
|
||||||
|
"N_MFCC = 40 # Jumlah koefisien MFCC yang diambil\n",
|
||||||
|
"N_FFT = 4096 # Panjang FFT\n",
|
||||||
|
"HOP_LENGTH = 512 # Hop size\n",
|
||||||
|
"\n",
|
||||||
|
"X = [] # Menyimpan fitur MFCC\n",
|
||||||
|
"y = [] # Menyimpan label kata"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"**FUNGSI EKSTRASI MFCC**"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 12,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"Processed: Negatif/mindrabodoh1 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindrabodoh1.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindrabodoh10 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindrabodoh10.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindrabodoh2 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindrabodoh2.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindrabodoh3 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindrabodoh3.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindrabodoh4 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindrabodoh4.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindrabodoh5 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindrabodoh5.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindrabodoh6 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindrabodoh6.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindrabodoh7 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindrabodoh7.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindrabodoh8 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindrabodoh8.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindrabodoh9 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindrabodoh9.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindralicik1 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindralicik1.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindralicik10 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindralicik10.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindralicik2 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindralicik2.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindralicik3 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindralicik3.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindralicik4 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindralicik4.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindralicik5 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindralicik5.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindralicik6 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindralicik6.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindralicik7 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindralicik7.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindralicik8 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindralicik8.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindralicik9 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindralicik9.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindrasombong1 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindrasombong1.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindrasombong10 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindrasombong10.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindrasombong2 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindrasombong2.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindrasombong3 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindrasombong3.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindrasombong4 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindrasombong4.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindrasombong5 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindrasombong5.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindrasombong6 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindrasombong6.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindrasombong7 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindrasombong7.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindrasombong8 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindrasombong8.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindrasombong9 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/mindrasombong9.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniabodoh1 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniabodoh1.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniabodoh10 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniabodoh10.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniabodoh11 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniabodoh11.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniabodoh12 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniabodoh12.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniabodoh13 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniabodoh13.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniabodoh2 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniabodoh2.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniabodoh3 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniabodoh3.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniabodoh4 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniabodoh4.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniabodoh5 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniabodoh5.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniabodoh6 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniabodoh6.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniabodoh7 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniabodoh7.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniabodoh8 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniabodoh8.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniabodoh9 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniabodoh9.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/nanialicik1 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/nanialicik1.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/nanialicik10 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/nanialicik10.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/nanialicik11 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/nanialicik11.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/nanialicik12 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/nanialicik12.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/nanialicik13 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/nanialicik13.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/nanialicik14 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/nanialicik14.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/nanialicik2 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/nanialicik2.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/nanialicik3 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/nanialicik3.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/nanialicik4 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/nanialicik4.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/nanialicik5 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/nanialicik5.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/nanialicik6 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/nanialicik6.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/nanialicik7 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/nanialicik7.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/nanialicik8 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/nanialicik8.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/nanialicik9 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/nanialicik9.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniasombong1 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniasombong1.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniasombong10 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniasombong10.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniasombong11 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniasombong11.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniasombong12 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniasombong12.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniasombong13 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniasombong13.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniasombong2 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniasombong2.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniasombong3 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniasombong3.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniasombong4 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniasombong4.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniasombong5 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniasombong5.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniasombong6 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniasombong6.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniasombong7 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniasombong7.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniasombong8 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniasombong8.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniasombong9 - Copy.wav → Label: Negatif\n",
|
||||||
|
"Processed: Negatif/naniasombong9.wav → Label: Negatif\n",
|
||||||
|
"Processed: Positif/mindrabai8 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrabai8.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrabaik1 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrabaik1.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrabaik10 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrabaik10.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrabaik2 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrabaik2.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrabaik3 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrabaik3.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrabaik4 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrabaik4.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrabaik5 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrabaik5.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrabaik6 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrabaik6.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrabaik7 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrabaik7.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrabaik8 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrabaik8.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrabaik9 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrabaik9.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrarajin1 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrarajin1.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrarajin10 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrarajin10.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrarajin2 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrarajin2.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrarajin3 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrarajin3.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrarajin4 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrarajin4.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrarajin5 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrarajin5.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrarajin6 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrarajin6.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrarajin7 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrarajin7.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrarajin8 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrarajin8.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrarajin9 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/mindrarajin9.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniabaik1 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniabaik1.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniabaik10 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniabaik10.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniabaik11 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniabaik11.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniabaik12 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniabaik12.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniabaik13 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniabaik13.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniabaik14 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniabaik14.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniabaik15 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniabaik15.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniabaik16 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniabaik16.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniabaik2 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniabaik2.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniabaik3 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniabaik3.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniabaik4 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniabaik4.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniabaik5 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniabaik5.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniabaik6 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniabaik6.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniabaik7 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniabaik7.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniabaik8 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniabaik8.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniabaik9 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniabaik9.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniarajin1 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniarajin1.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniarajin10 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniarajin10.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniarajin11 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniarajin11.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniarajin12 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniarajin12.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniarajin13 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniarajin13.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniarajin14 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniarajin14.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniarajin2 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniarajin2.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniarajin3 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniarajin3.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniarajin4 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniarajin4.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniarajin5 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniarajin5.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniarajin6 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniarajin6.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniarajin7 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniarajin7.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniarajin8 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniarajin8.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniarajin9 - Copy.wav → Label: Positif\n",
|
||||||
|
"Processed: Positif/naniarajin9.wav → Label: Positif\n",
|
||||||
|
"Ekstraksi MFCC selesai. Dataset tersimpan di folder 'E:\\! KULIAHHH\\Ivano Kuliah\\!SEMESTER 8\\!SKRIPSI\\Data Suara\\!REVISI\\hasil_ekstrak_mfcc_v2'.\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"def extract_mfcc(file_path):\n",
|
||||||
|
" \"\"\"Ekstraksi fitur MFCC dari file audio.\"\"\"\n",
|
||||||
|
" y_audio, sr = librosa.load(file_path, sr=SAMPLE_RATE)\n",
|
||||||
|
" mfcc = librosa.feature.mfcc(y=y_audio, sr=sr, n_mfcc=N_MFCC, n_fft=N_FFT, hop_length=HOP_LENGTH, lifter=22)\n",
|
||||||
|
" return np.mean(mfcc, axis=1) # Rata-rata per koefisien\n",
|
||||||
|
"\n",
|
||||||
|
"file_names = [] # Tambahan untuk menyimpan nama file\n",
|
||||||
|
"\n",
|
||||||
|
"# Looping folder Positif dan Negatif\n",
|
||||||
|
"for label_folder in os.listdir(DATASET_PATH):\n",
|
||||||
|
" label_path = os.path.join(DATASET_PATH, label_folder)\n",
|
||||||
|
"\n",
|
||||||
|
" if os.path.isdir(label_path):\n",
|
||||||
|
" for file_name in os.listdir(label_path):\n",
|
||||||
|
" if file_name.endswith(\".wav\"):\n",
|
||||||
|
" file_path = os.path.join(label_path, file_name)\n",
|
||||||
|
" mfcc_features = extract_mfcc(file_path)\n",
|
||||||
|
"\n",
|
||||||
|
" X.append(mfcc_features)\n",
|
||||||
|
" y.append(label_folder)\n",
|
||||||
|
" file_names.append(f\"{label_folder}/{file_name}\") # Simpan dengan labelnya biar mudah dilacak\n",
|
||||||
|
"\n",
|
||||||
|
" print(f\"Processed: {label_folder}/{file_name} → Label: {label_folder}\")\n",
|
||||||
|
"\n",
|
||||||
|
"# Konversi ke array numpy\n",
|
||||||
|
"X = np.array(X)\n",
|
||||||
|
"y = np.array(y)\n",
|
||||||
|
"\n",
|
||||||
|
"# Simpan hasil\n",
|
||||||
|
"np.save(OUTPUT_FEATURES, X)\n",
|
||||||
|
"np.save(OUTPUT_LABELS, y)\n",
|
||||||
|
"np.save(os.path.join(OUTPUT_FOLDER, \"file_names.npy\"), np.array(file_names)) # Tambahan\n",
|
||||||
|
"\n",
|
||||||
|
"print(f\"Ekstraksi MFCC selesai. Dataset tersimpan di folder '{OUTPUT_FOLDER}'.\")"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 2
|
||||||
|
}
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,444 @@
|
||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"**LIBRARY**"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 22,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import librosa\n",
|
||||||
|
"import librosa.display\n",
|
||||||
|
"import numpy as np\n",
|
||||||
|
"import noisereduce as nr\n",
|
||||||
|
"import os\n",
|
||||||
|
"import soundfile as sf"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"**PARAMETER**"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 23,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# Parameter\n",
|
||||||
|
"TARGET_DURATION = 1.0 # Durasi target dalam detik\n",
|
||||||
|
"SAMPLE_RATE = 48000 # Frekuensi sampling sesuai dataset (48 kHz)\n",
|
||||||
|
"DATASET_PATH = \"EDITED3\" # Ganti dengan path dataset\n",
|
||||||
|
"OUTPUT_DIR = \"E:\\! KULIAHHH\\Ivano Kuliah\\!SEMESTER 8\\!SKRIPSI\\Data Suara\\!REVISI\\preprocessing_data_v2\" # Folder untuk menyimpan hasil preprocessing\n",
|
||||||
|
"\n",
|
||||||
|
"# Pastikan folder output ada\n",
|
||||||
|
"os.makedirs(OUTPUT_DIR, exist_ok=True)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"**LOAD DATASET**"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 24,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"def load_audio(file_path, sr=SAMPLE_RATE):\n",
|
||||||
|
" \"\"\"Membaca file audio dan mengembalikan waveform serta sample rate.\"\"\"\n",
|
||||||
|
" y, sr = librosa.load(file_path, sr=sr)\n",
|
||||||
|
" return y, sr"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"**NORMALISASI AUDIO**"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 25,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"def normalize_audio(y):\n",
|
||||||
|
" \"\"\"Normalisasi amplitudo antara -1 dan 1.\"\"\"\n",
|
||||||
|
" return y / np.max(np.abs(y))"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"**PADDING AUDIO ATAU CUT**"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 26,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"def pad_audio(y, sr=SAMPLE_RATE, target_duration=TARGET_DURATION):\n",
|
||||||
|
" \"\"\"Menyesuaikan durasi audio dengan padding atau pemotongan.\"\"\"\n",
|
||||||
|
" target_length = int(sr * target_duration) # Hitung jumlah sampel target\n",
|
||||||
|
" if len(y) > target_length:\n",
|
||||||
|
" return y[:target_length] # Potong jika lebih panjang\n",
|
||||||
|
" else:\n",
|
||||||
|
" return np.pad(y, (0, target_length - len(y)), mode='constant') # Tambahkan padding"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"**NOISE REDUCTION**"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 27,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"def reduce_noise(y, sr=SAMPLE_RATE):\n",
|
||||||
|
" \"\"\"Mengurangi noise dengan noisereduce.\"\"\"\n",
|
||||||
|
" return nr.reduce_noise(y=y, sr=sr)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"**PREPROCESS AUDIO**"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 28,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"Processed: Negatif/mindrabodoh1 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/mindrabodoh1.wav\n",
|
||||||
|
"Processed: Negatif/mindrabodoh10 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/mindrabodoh10.wav\n",
|
||||||
|
"Processed: Negatif/mindrabodoh2 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/mindrabodoh2.wav\n",
|
||||||
|
"Processed: Negatif/mindrabodoh3 - Copy.wav\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"Processed: Negatif/mindrabodoh3.wav\n",
|
||||||
|
"Processed: Negatif/mindrabodoh4 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/mindrabodoh4.wav\n",
|
||||||
|
"Processed: Negatif/mindrabodoh5 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/mindrabodoh5.wav\n",
|
||||||
|
"Processed: Negatif/mindrabodoh6 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/mindrabodoh6.wav\n",
|
||||||
|
"Processed: Negatif/mindrabodoh7 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/mindrabodoh7.wav\n",
|
||||||
|
"Processed: Negatif/mindrabodoh8 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/mindrabodoh8.wav\n",
|
||||||
|
"Processed: Negatif/mindrabodoh9 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/mindrabodoh9.wav\n",
|
||||||
|
"Processed: Negatif/mindralicik1 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/mindralicik1.wav\n",
|
||||||
|
"Processed: Negatif/mindralicik10 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/mindralicik10.wav\n",
|
||||||
|
"Processed: Negatif/mindralicik2 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/mindralicik2.wav\n",
|
||||||
|
"Processed: Negatif/mindralicik3 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/mindralicik3.wav\n",
|
||||||
|
"Processed: Negatif/mindralicik4 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/mindralicik4.wav\n",
|
||||||
|
"Processed: Negatif/mindralicik5 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/mindralicik5.wav\n",
|
||||||
|
"Processed: Negatif/mindralicik6 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/mindralicik6.wav\n",
|
||||||
|
"Processed: Negatif/mindralicik7 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/mindralicik7.wav\n",
|
||||||
|
"Processed: Negatif/mindralicik8 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/mindralicik8.wav\n",
|
||||||
|
"Processed: Negatif/mindralicik9 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/mindralicik9.wav\n",
|
||||||
|
"Processed: Negatif/mindrasombong1 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/mindrasombong1.wav\n",
|
||||||
|
"Processed: Negatif/mindrasombong10 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/mindrasombong10.wav\n",
|
||||||
|
"Processed: Negatif/mindrasombong2 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/mindrasombong2.wav\n",
|
||||||
|
"Processed: Negatif/mindrasombong3 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/mindrasombong3.wav\n",
|
||||||
|
"Processed: Negatif/mindrasombong4 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/mindrasombong4.wav\n",
|
||||||
|
"Processed: Negatif/mindrasombong5 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/mindrasombong5.wav\n",
|
||||||
|
"Processed: Negatif/mindrasombong6 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/mindrasombong6.wav\n",
|
||||||
|
"Processed: Negatif/mindrasombong7 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/mindrasombong7.wav\n",
|
||||||
|
"Processed: Negatif/mindrasombong8 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/mindrasombong8.wav\n",
|
||||||
|
"Processed: Negatif/mindrasombong9 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/mindrasombong9.wav\n",
|
||||||
|
"Processed: Negatif/naniabodoh1 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/naniabodoh1.wav\n",
|
||||||
|
"Processed: Negatif/naniabodoh10 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/naniabodoh10.wav\n",
|
||||||
|
"Processed: Negatif/naniabodoh11 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/naniabodoh11.wav\n",
|
||||||
|
"Processed: Negatif/naniabodoh12 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/naniabodoh12.wav\n",
|
||||||
|
"Processed: Negatif/naniabodoh13 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/naniabodoh13.wav\n",
|
||||||
|
"Processed: Negatif/naniabodoh2 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/naniabodoh2.wav\n",
|
||||||
|
"Processed: Negatif/naniabodoh3 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/naniabodoh3.wav\n",
|
||||||
|
"Processed: Negatif/naniabodoh4 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/naniabodoh4.wav\n",
|
||||||
|
"Processed: Negatif/naniabodoh5 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/naniabodoh5.wav\n",
|
||||||
|
"Processed: Negatif/naniabodoh6 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/naniabodoh6.wav\n",
|
||||||
|
"Processed: Negatif/naniabodoh7 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/naniabodoh7.wav\n",
|
||||||
|
"Processed: Negatif/naniabodoh8 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/naniabodoh8.wav\n",
|
||||||
|
"Processed: Negatif/naniabodoh9 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/naniabodoh9.wav\n",
|
||||||
|
"Processed: Negatif/nanialicik1 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/nanialicik1.wav\n",
|
||||||
|
"Processed: Negatif/nanialicik10 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/nanialicik10.wav\n",
|
||||||
|
"Processed: Negatif/nanialicik11 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/nanialicik11.wav\n",
|
||||||
|
"Processed: Negatif/nanialicik12 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/nanialicik12.wav\n",
|
||||||
|
"Processed: Negatif/nanialicik13 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/nanialicik13.wav\n",
|
||||||
|
"Processed: Negatif/nanialicik14 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/nanialicik14.wav\n",
|
||||||
|
"Processed: Negatif/nanialicik2 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/nanialicik2.wav\n",
|
||||||
|
"Processed: Negatif/nanialicik3 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/nanialicik3.wav\n",
|
||||||
|
"Processed: Negatif/nanialicik4 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/nanialicik4.wav\n",
|
||||||
|
"Processed: Negatif/nanialicik5 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/nanialicik5.wav\n",
|
||||||
|
"Processed: Negatif/nanialicik6 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/nanialicik6.wav\n",
|
||||||
|
"Processed: Negatif/nanialicik7 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/nanialicik7.wav\n",
|
||||||
|
"Processed: Negatif/nanialicik8 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/nanialicik8.wav\n",
|
||||||
|
"Processed: Negatif/nanialicik9 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/nanialicik9.wav\n",
|
||||||
|
"Processed: Negatif/naniasombong1 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/naniasombong1.wav\n",
|
||||||
|
"Processed: Negatif/naniasombong10 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/naniasombong10.wav\n",
|
||||||
|
"Processed: Negatif/naniasombong11 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/naniasombong11.wav\n",
|
||||||
|
"Processed: Negatif/naniasombong12 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/naniasombong12.wav\n",
|
||||||
|
"Processed: Negatif/naniasombong13 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/naniasombong13.wav\n",
|
||||||
|
"Processed: Negatif/naniasombong2 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/naniasombong2.wav\n",
|
||||||
|
"Processed: Negatif/naniasombong3 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/naniasombong3.wav\n",
|
||||||
|
"Processed: Negatif/naniasombong4 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/naniasombong4.wav\n",
|
||||||
|
"Processed: Negatif/naniasombong5 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/naniasombong5.wav\n",
|
||||||
|
"Processed: Negatif/naniasombong6 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/naniasombong6.wav\n",
|
||||||
|
"Processed: Negatif/naniasombong7 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/naniasombong7.wav\n",
|
||||||
|
"Processed: Negatif/naniasombong8 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/naniasombong8.wav\n",
|
||||||
|
"Processed: Negatif/naniasombong9 - Copy.wav\n",
|
||||||
|
"Processed: Negatif/naniasombong9.wav\n",
|
||||||
|
"Processed: Positif/mindrabai8 - Copy.wav\n",
|
||||||
|
"Processed: Positif/mindrabai8.wav\n",
|
||||||
|
"Processed: Positif/mindrabaik1 - Copy.wav\n",
|
||||||
|
"Processed: Positif/mindrabaik1.wav\n",
|
||||||
|
"Processed: Positif/mindrabaik10 - Copy.wav\n",
|
||||||
|
"Processed: Positif/mindrabaik10.wav\n",
|
||||||
|
"Processed: Positif/mindrabaik2 - Copy.wav\n",
|
||||||
|
"Processed: Positif/mindrabaik2.wav\n",
|
||||||
|
"Processed: Positif/mindrabaik3 - Copy.wav\n",
|
||||||
|
"Processed: Positif/mindrabaik3.wav\n",
|
||||||
|
"Processed: Positif/mindrabaik4 - Copy.wav\n",
|
||||||
|
"Processed: Positif/mindrabaik4.wav\n",
|
||||||
|
"Processed: Positif/mindrabaik5 - Copy.wav\n",
|
||||||
|
"Processed: Positif/mindrabaik5.wav\n",
|
||||||
|
"Processed: Positif/mindrabaik6 - Copy.wav\n",
|
||||||
|
"Processed: Positif/mindrabaik6.wav\n",
|
||||||
|
"Processed: Positif/mindrabaik7 - Copy.wav\n",
|
||||||
|
"Processed: Positif/mindrabaik7.wav\n",
|
||||||
|
"Processed: Positif/mindrabaik8 - Copy.wav\n",
|
||||||
|
"Processed: Positif/mindrabaik8.wav\n",
|
||||||
|
"Processed: Positif/mindrabaik9 - Copy.wav\n",
|
||||||
|
"Processed: Positif/mindrabaik9.wav\n",
|
||||||
|
"Processed: Positif/mindrarajin1 - Copy.wav\n",
|
||||||
|
"Processed: Positif/mindrarajin1.wav\n",
|
||||||
|
"Processed: Positif/mindrarajin10 - Copy.wav\n",
|
||||||
|
"Processed: Positif/mindrarajin10.wav\n",
|
||||||
|
"Processed: Positif/mindrarajin2 - Copy.wav\n",
|
||||||
|
"Processed: Positif/mindrarajin2.wav\n",
|
||||||
|
"Processed: Positif/mindrarajin3 - Copy.wav\n",
|
||||||
|
"Processed: Positif/mindrarajin3.wav\n",
|
||||||
|
"Processed: Positif/mindrarajin4 - Copy.wav\n",
|
||||||
|
"Processed: Positif/mindrarajin4.wav\n",
|
||||||
|
"Processed: Positif/mindrarajin5 - Copy.wav\n",
|
||||||
|
"Processed: Positif/mindrarajin5.wav\n",
|
||||||
|
"Processed: Positif/mindrarajin6 - Copy.wav\n",
|
||||||
|
"Processed: Positif/mindrarajin6.wav\n",
|
||||||
|
"Processed: Positif/mindrarajin7 - Copy.wav\n",
|
||||||
|
"Processed: Positif/mindrarajin7.wav\n",
|
||||||
|
"Processed: Positif/mindrarajin8 - Copy.wav\n",
|
||||||
|
"Processed: Positif/mindrarajin8.wav\n",
|
||||||
|
"Processed: Positif/mindrarajin9 - Copy.wav\n",
|
||||||
|
"Processed: Positif/mindrarajin9.wav\n",
|
||||||
|
"Processed: Positif/naniabaik1 - Copy.wav\n",
|
||||||
|
"Processed: Positif/naniabaik1.wav\n",
|
||||||
|
"Processed: Positif/naniabaik10 - Copy.wav\n",
|
||||||
|
"Processed: Positif/naniabaik10.wav\n",
|
||||||
|
"Processed: Positif/naniabaik11 - Copy.wav\n",
|
||||||
|
"Processed: Positif/naniabaik11.wav\n",
|
||||||
|
"Processed: Positif/naniabaik12 - Copy.wav\n",
|
||||||
|
"Processed: Positif/naniabaik12.wav\n",
|
||||||
|
"Processed: Positif/naniabaik13 - Copy.wav\n",
|
||||||
|
"Processed: Positif/naniabaik13.wav\n",
|
||||||
|
"Processed: Positif/naniabaik14 - Copy.wav\n",
|
||||||
|
"Processed: Positif/naniabaik14.wav\n",
|
||||||
|
"Processed: Positif/naniabaik15 - Copy.wav\n",
|
||||||
|
"Processed: Positif/naniabaik15.wav\n",
|
||||||
|
"Processed: Positif/naniabaik16 - Copy.wav\n",
|
||||||
|
"Processed: Positif/naniabaik16.wav\n",
|
||||||
|
"Processed: Positif/naniabaik2 - Copy.wav\n",
|
||||||
|
"Processed: Positif/naniabaik2.wav\n",
|
||||||
|
"Processed: Positif/naniabaik3 - Copy.wav\n",
|
||||||
|
"Processed: Positif/naniabaik3.wav\n",
|
||||||
|
"Processed: Positif/naniabaik4 - Copy.wav\n",
|
||||||
|
"Processed: Positif/naniabaik4.wav\n",
|
||||||
|
"Processed: Positif/naniabaik5 - Copy.wav\n",
|
||||||
|
"Processed: Positif/naniabaik5.wav\n",
|
||||||
|
"Processed: Positif/naniabaik6 - Copy.wav\n",
|
||||||
|
"Processed: Positif/naniabaik6.wav\n",
|
||||||
|
"Processed: Positif/naniabaik7 - Copy.wav\n",
|
||||||
|
"Processed: Positif/naniabaik7.wav\n",
|
||||||
|
"Processed: Positif/naniabaik8 - Copy.wav\n",
|
||||||
|
"Processed: Positif/naniabaik8.wav\n",
|
||||||
|
"Processed: Positif/naniabaik9 - Copy.wav\n",
|
||||||
|
"Processed: Positif/naniabaik9.wav\n",
|
||||||
|
"Processed: Positif/naniarajin1 - Copy.wav\n",
|
||||||
|
"Processed: Positif/naniarajin1.wav\n",
|
||||||
|
"Processed: Positif/naniarajin10 - Copy.wav\n",
|
||||||
|
"Processed: Positif/naniarajin10.wav\n",
|
||||||
|
"Processed: Positif/naniarajin11 - Copy.wav\n",
|
||||||
|
"Processed: Positif/naniarajin11.wav\n",
|
||||||
|
"Processed: Positif/naniarajin12 - Copy.wav\n",
|
||||||
|
"Processed: Positif/naniarajin12.wav\n",
|
||||||
|
"Processed: Positif/naniarajin13 - Copy.wav\n",
|
||||||
|
"Processed: Positif/naniarajin13.wav\n",
|
||||||
|
"Processed: Positif/naniarajin14 - Copy.wav\n",
|
||||||
|
"Processed: Positif/naniarajin14.wav\n",
|
||||||
|
"Processed: Positif/naniarajin2 - Copy.wav\n",
|
||||||
|
"Processed: Positif/naniarajin2.wav\n",
|
||||||
|
"Processed: Positif/naniarajin3 - Copy.wav\n",
|
||||||
|
"Processed: Positif/naniarajin3.wav\n",
|
||||||
|
"Processed: Positif/naniarajin4 - Copy.wav\n",
|
||||||
|
"Processed: Positif/naniarajin4.wav\n",
|
||||||
|
"Processed: Positif/naniarajin5 - Copy.wav\n",
|
||||||
|
"Processed: Positif/naniarajin5.wav\n",
|
||||||
|
"Processed: Positif/naniarajin6 - Copy.wav\n",
|
||||||
|
"Processed: Positif/naniarajin6.wav\n",
|
||||||
|
"Processed: Positif/naniarajin7 - Copy.wav\n",
|
||||||
|
"Processed: Positif/naniarajin7.wav\n",
|
||||||
|
"Processed: Positif/naniarajin8 - Copy.wav\n",
|
||||||
|
"Processed: Positif/naniarajin8.wav\n",
|
||||||
|
"Processed: Positif/naniarajin9 - Copy.wav\n",
|
||||||
|
"Processed: Positif/naniarajin9.wav\n",
|
||||||
|
"Preprocessing selesai. Hasil disimpan di folder 'preprocessing_data'.\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"def preprocess_audio(file_path, output_path):\n",
|
||||||
|
" \"\"\"Melakukan preprocessing (normalisasi, padding, noise reduction) pada file audio.\"\"\"\n",
|
||||||
|
" y, sr = load_audio(file_path)\n",
|
||||||
|
" y = reduce_noise(y, sr)\n",
|
||||||
|
" y = normalize_audio(y)\n",
|
||||||
|
" y = pad_audio(y, sr)\n",
|
||||||
|
" \n",
|
||||||
|
" # Simpan hasil preprocessing\n",
|
||||||
|
" sf.write(output_path, y, sr)\n",
|
||||||
|
"\n",
|
||||||
|
"# Looping folder Positif dan Negatif\n",
|
||||||
|
"for label_folder in os.listdir(DATASET_PATH):\n",
|
||||||
|
" label_path = os.path.join(DATASET_PATH, label_folder)\n",
|
||||||
|
" \n",
|
||||||
|
" if os.path.isdir(label_path): # Pastikan itu folder Positif / Negatif\n",
|
||||||
|
" output_label_path = os.path.join(OUTPUT_DIR, label_folder)\n",
|
||||||
|
" os.makedirs(output_label_path, exist_ok=True)\n",
|
||||||
|
"\n",
|
||||||
|
" # Looping file WAV di dalam folder\n",
|
||||||
|
" for file_name in os.listdir(label_path):\n",
|
||||||
|
" if file_name.endswith(\".wav\"):\n",
|
||||||
|
" input_path = os.path.join(label_path, file_name)\n",
|
||||||
|
" output_path = os.path.join(output_label_path, file_name)\n",
|
||||||
|
" preprocess_audio(input_path, output_path)\n",
|
||||||
|
" print(f\"Processed: {label_folder}/{file_name}\")\n",
|
||||||
|
"\n",
|
||||||
|
"print(\"Preprocessing selesai. Hasil disimpan di folder 'preprocessing_data'.\")"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 2
|
||||||
|
}
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,181 @@
|
||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 7,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import seaborn as sns\n",
|
||||||
|
"import matplotlib.pyplot as plt\n",
|
||||||
|
"import numpy as np\n",
|
||||||
|
"import sklearn.preprocessing as pre\n",
|
||||||
|
"from sklearn.model_selection import train_test_split, StratifiedKFold\n",
|
||||||
|
"from sklearn.metrics import accuracy_score, confusion_matrix, classification_report\n",
|
||||||
|
"import joblib"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 8,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"X = np.load(\"E:\\! KULIAHHH\\Ivano Kuliah\\!SEMESTER 8\\!SKRIPSI\\Data Suara\\!REVISI\\hasil_ekstrak_mfcc_v2/X_train.npy\")\n",
|
||||||
|
"y = np.load(\"E:\\! KULIAHHH\\Ivano Kuliah\\!SEMESTER 8\\!SKRIPSI\\Data Suara\\!REVISI\\hasil_ekstrak_mfcc_v2/y_train.npy\")"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 9,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# Encode label menjadi angka\n",
|
||||||
|
"label_encoder = pre.LabelEncoder()\n",
|
||||||
|
"y_encoded = label_encoder.fit_transform(y)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 10,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# Inisialisasi K-Fold Cross-Validation\n",
|
||||||
|
"k = 5 # Jumlah fold\n",
|
||||||
|
"kf = StratifiedKFold(n_splits=k, shuffle=True, random_state=42)\n",
|
||||||
|
"accuracies = [] # Simpan akurasi tiap fold"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 11,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"class LVQ:\n",
|
||||||
|
" def __init__(self, n_classes, n_prototypes=2, learning_rate=0.01, epochs=200):\n",
|
||||||
|
" self.n_classes = n_classes\n",
|
||||||
|
" self.n_prototypes = n_prototypes\n",
|
||||||
|
" self.learning_rate = learning_rate\n",
|
||||||
|
" self.epochs = epochs\n",
|
||||||
|
" self.prototypes = None\n",
|
||||||
|
" self.prototype_labels = None\n",
|
||||||
|
"\n",
|
||||||
|
" def fit(self, X, y):\n",
|
||||||
|
" np.random.seed(42)\n",
|
||||||
|
" self.prototypes = []\n",
|
||||||
|
" self.prototype_labels = []\n",
|
||||||
|
"\n",
|
||||||
|
" for label in np.unique(y):\n",
|
||||||
|
" idx = np.where(y == label)[0]\n",
|
||||||
|
" chosen = np.random.choice(idx, self.n_prototypes, replace=False)\n",
|
||||||
|
" self.prototypes.extend(X[chosen])\n",
|
||||||
|
" self.prototype_labels.extend([label] * self.n_prototypes)\n",
|
||||||
|
"\n",
|
||||||
|
" self.prototypes = np.array(self.prototypes)\n",
|
||||||
|
" self.prototype_labels = np.array(self.prototype_labels)\n",
|
||||||
|
"\n",
|
||||||
|
" for epoch in range(self.epochs):\n",
|
||||||
|
" for i in range(len(X)):\n",
|
||||||
|
" sample = X[i]\n",
|
||||||
|
" label = y[i]\n",
|
||||||
|
" distances = np.linalg.norm(self.prototypes - sample, axis=1)\n",
|
||||||
|
" winner_idx = np.argmin(distances)\n",
|
||||||
|
"\n",
|
||||||
|
" if self.prototype_labels[winner_idx] == label:\n",
|
||||||
|
" self.prototypes[winner_idx] += self.learning_rate * (sample - self.prototypes[winner_idx])\n",
|
||||||
|
" else:\n",
|
||||||
|
" self.prototypes[winner_idx] -= self.learning_rate * (sample - self.prototypes[winner_idx])\n",
|
||||||
|
"\n",
|
||||||
|
" self.learning_rate *= 0.95\n",
|
||||||
|
"\n",
|
||||||
|
" def predict(self, X):\n",
|
||||||
|
" y_pred = []\n",
|
||||||
|
" for sample in X:\n",
|
||||||
|
" distances = np.linalg.norm(self.prototypes - sample, axis=1)\n",
|
||||||
|
" winner_idx = np.argmin(distances)\n",
|
||||||
|
" y_pred.append(self.prototype_labels[winner_idx])\n",
|
||||||
|
" return np.array(y_pred)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 12,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"🔄 Fold 1/5...\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"✅ Akurasi Fold 1: 79.59%\n",
|
||||||
|
"🔄 Fold 2/5...\n",
|
||||||
|
"✅ Akurasi Fold 2: 87.76%\n",
|
||||||
|
"🔄 Fold 3/5...\n",
|
||||||
|
"✅ Akurasi Fold 3: 77.08%\n",
|
||||||
|
"🔄 Fold 4/5...\n",
|
||||||
|
"✅ Akurasi Fold 4: 83.33%\n",
|
||||||
|
"🔄 Fold 5/5...\n",
|
||||||
|
"✅ Akurasi Fold 5: 70.83%\n",
|
||||||
|
"\n",
|
||||||
|
"📊 Rata-rata Akurasi dari 5-Fold Cross Validation: 79.72%\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"# K-Fold Cross-Validation\n",
|
||||||
|
"for fold, (train_idx, test_idx) in enumerate(kf.split(X, y_encoded)):\n",
|
||||||
|
" print(f\"🔄 Fold {fold+1}/{k}...\")\n",
|
||||||
|
"\n",
|
||||||
|
" # Split data untuk fold ini\n",
|
||||||
|
" X_train, X_test = X[train_idx], X[test_idx]\n",
|
||||||
|
" y_train, y_test = y_encoded[train_idx], y_encoded[test_idx]\n",
|
||||||
|
"\n",
|
||||||
|
" # Inisialisasi dan training model LVQ\n",
|
||||||
|
" lvq_model = LVQ(n_classes=len(set(y_encoded)), n_prototypes=2, learning_rate=0.01, epochs=200)\n",
|
||||||
|
" lvq_model.fit(X_train, y_train)\n",
|
||||||
|
"\n",
|
||||||
|
" # Prediksi data uji\n",
|
||||||
|
" y_pred = lvq_model.predict(X_test)\n",
|
||||||
|
"\n",
|
||||||
|
" # Evaluasi\n",
|
||||||
|
" accuracy = accuracy_score(y_test, y_pred)\n",
|
||||||
|
" accuracies.append(accuracy)\n",
|
||||||
|
" print(f\"✅ Akurasi Fold {fold+1}: {accuracy * 100:.2f}%\")\n",
|
||||||
|
"\n",
|
||||||
|
"# Hitung rata-rata akurasi dari semua fold\n",
|
||||||
|
"mean_accuracy = np.mean(accuracies)\n",
|
||||||
|
"print(f\"\\n📊 Rata-rata Akurasi dari {k}-Fold Cross Validation: {mean_accuracy * 100:.2f}%\")\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 2
|
||||||
|
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue