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