Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- app.py +31 -0
- requirements.txt +5 -0
app.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from keras.models import load_model
|
3 |
+
import librosa
|
4 |
+
import numpy as np
|
5 |
+
import pickle
|
6 |
+
|
7 |
+
# Model ve eğitim tarihçesini yükle
|
8 |
+
model = load_model('my_model.h5')
|
9 |
+
with open('pkl.pkl', 'rb') as file_pi:
|
10 |
+
history = pickle.load(file_pi)
|
11 |
+
|
12 |
+
def detect_fake(sound_file):
|
13 |
+
sound_signal, sample_rate = librosa.load(sound_file, res_type="kaiser_fast")
|
14 |
+
mfcc_features = librosa.feature.mfcc(y=sound_signal, sr=sample_rate, n_mfcc=40)
|
15 |
+
mfccs_features_scaled = np.mean(mfcc_features.T, axis=0)
|
16 |
+
mfccs_features_scaled = mfccs_features_scaled.reshape(1, -1)
|
17 |
+
result_array = model.predict(mfccs_features_scaled)
|
18 |
+
result_classes = ["FAKE", "REAL"]
|
19 |
+
result = np.argmax(result_array[0])
|
20 |
+
return result_classes[result]
|
21 |
+
|
22 |
+
# Streamlit arayüzü
|
23 |
+
st.title('Ses Doğrulama Sistemi')
|
24 |
+
|
25 |
+
uploaded_file = st.file_uploader("Ses dosyası yükle", type=["wav", "mp3", "ogg"])
|
26 |
+
if uploaded_file is not None:
|
27 |
+
# Dosyayı kaydet
|
28 |
+
with open(uploaded_file.name, "wb") as f:
|
29 |
+
f.write(uploaded_file.getbuffer())
|
30 |
+
result = detect_fake(uploaded_file.name)
|
31 |
+
st.write(f"Tahmin: {result}")
|
requirements.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
streamlit
|
2 |
+
keras
|
3 |
+
librosa
|
4 |
+
numpy
|
5 |
+
pickle5
|