Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,13 @@
|
|
1 |
-
|
2 |
import speech_recognition as sr
|
3 |
import requests
|
4 |
-
import smtplib
|
5 |
-
from email.message import EmailMessage
|
6 |
from transformers import pipeline
|
7 |
from reportlab.pdfgen import canvas
|
|
|
|
|
8 |
import os
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
# Google Speech-to-Text API Anahtarı (JSON dosyanızın yolu)
|
13 |
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "your-google-cloud-key.json"
|
14 |
|
15 |
# Gemini API Anahtarı
|
@@ -18,60 +16,56 @@ GEMINI_API_KEY = "your-gemini-api-key"
|
|
18 |
# Hugging Face Özetleme Modeli
|
19 |
summary_pipeline = pipeline("summarization", model="facebook/bart-large-cnn")
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
if 'audio' not in request.files:
|
25 |
-
return jsonify({"error": "No audio file provided"}), 400
|
26 |
-
|
27 |
-
audio_file = request.files['audio']
|
28 |
-
recognizer = sr.Recognizer()
|
29 |
|
30 |
-
|
|
|
|
|
|
|
31 |
audio_data = recognizer.record(source)
|
32 |
try:
|
33 |
text = recognizer.recognize_google(audio_data, language="tr-TR")
|
34 |
-
return
|
35 |
except sr.UnknownValueError:
|
36 |
-
return
|
37 |
except sr.RequestError:
|
38 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
### 📌 2️⃣ Metni Özetleme (Gemini API) ###
|
41 |
def summarize_text(text):
|
42 |
url = "https://generativelanguage.googleapis.com/v1/models/gemini-pro:generateText"
|
43 |
headers = {"Authorization": f"Bearer {GEMINI_API_KEY}"}
|
44 |
-
payload = {
|
45 |
-
"prompt": f"Summarize this meeting transcript:\n{text}",
|
46 |
-
"max_tokens": 500
|
47 |
-
}
|
48 |
response = requests.post(url, json=payload, headers=headers)
|
49 |
return response.json()["choices"][0]["text"]
|
50 |
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
return jsonify({"error": "No text provided"}), 400
|
57 |
|
58 |
-
|
59 |
-
return jsonify({"summary": summary})
|
60 |
-
|
61 |
-
### 📌 3️⃣ Kararları Çıkarma (Hugging Face NLP) ###
|
62 |
def extract_decisions(text):
|
63 |
summary = summary_pipeline(text, max_length=100, min_length=30, do_sample=False)
|
64 |
return summary[0]['summary_text']
|
65 |
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
return jsonify({"error": "No text provided"}), 400
|
72 |
-
|
73 |
-
decisions = extract_decisions(text)
|
74 |
-
return jsonify({"decisions": decisions})
|
75 |
|
76 |
### 📌 4️⃣ PDF Raporu Oluşturma ###
|
77 |
def create_pdf(text, filename="meeting_report.pdf"):
|
@@ -81,15 +75,12 @@ def create_pdf(text, filename="meeting_report.pdf"):
|
|
81 |
c.save()
|
82 |
return filename
|
83 |
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
pdf_file = create_pdf(text)
|
92 |
-
return send_file(pdf_file, as_attachment=True)
|
93 |
|
94 |
### 📌 5️⃣ E-Posta Gönderme ###
|
95 |
def send_email(pdf_file, recipient_email):
|
@@ -110,9 +101,9 @@ def send_email(pdf_file, recipient_email):
|
|
110 |
server.login(email, password)
|
111 |
server.send_message(msg)
|
112 |
|
113 |
-
|
114 |
-
|
115 |
-
|
|
|
|
|
116 |
|
117 |
-
if __name__ == '__main__':
|
118 |
-
app.run(debug=True)
|
|
|
1 |
+
import streamlit as st
|
2 |
import speech_recognition as sr
|
3 |
import requests
|
|
|
|
|
4 |
from transformers import pipeline
|
5 |
from reportlab.pdfgen import canvas
|
6 |
+
import smtplib
|
7 |
+
from email.message import EmailMessage
|
8 |
import os
|
9 |
|
10 |
+
# Google Speech-to-Text API Anahtarı
|
|
|
|
|
11 |
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "your-google-cloud-key.json"
|
12 |
|
13 |
# Gemini API Anahtarı
|
|
|
16 |
# Hugging Face Özetleme Modeli
|
17 |
summary_pipeline = pipeline("summarization", model="facebook/bart-large-cnn")
|
18 |
|
19 |
+
# Streamlit Sayfası Başlığı
|
20 |
+
st.set_page_config(page_title="AI-Powered Meeting Notes & Reporting", layout="wide")
|
21 |
+
st.title("📢 AI Meeting Notes & Reporting System")
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
+
### 📌 1️⃣ Speech-to-Text (Konuşmayı Metne Çevirme) ###
|
24 |
+
def speech_to_text(audio_path):
|
25 |
+
recognizer = sr.Recognizer()
|
26 |
+
with sr.AudioFile(audio_path) as source:
|
27 |
audio_data = recognizer.record(source)
|
28 |
try:
|
29 |
text = recognizer.recognize_google(audio_data, language="tr-TR")
|
30 |
+
return text
|
31 |
except sr.UnknownValueError:
|
32 |
+
return "❌ Ses anlaşılamadı."
|
33 |
except sr.RequestError:
|
34 |
+
return "❌ Google API'ye erişilemiyor."
|
35 |
+
|
36 |
+
uploaded_audio = st.file_uploader("🔊 Ses dosyanızı yükleyin (WAV formatında)", type=["wav"])
|
37 |
+
if uploaded_audio:
|
38 |
+
with open("temp.wav", "wb") as f:
|
39 |
+
f.write(uploaded_audio.getbuffer())
|
40 |
+
st.audio(uploaded_audio, format="audio/wav")
|
41 |
+
transcript = speech_to_text("temp.wav")
|
42 |
+
st.subheader("🎤 Metne Dönüştürülen Konuşma:")
|
43 |
+
st.write(transcript)
|
44 |
|
45 |
### 📌 2️⃣ Metni Özetleme (Gemini API) ###
|
46 |
def summarize_text(text):
|
47 |
url = "https://generativelanguage.googleapis.com/v1/models/gemini-pro:generateText"
|
48 |
headers = {"Authorization": f"Bearer {GEMINI_API_KEY}"}
|
49 |
+
payload = {"prompt": f"Summarize the following meeting transcript:\n{text}", "max_tokens": 500}
|
|
|
|
|
|
|
50 |
response = requests.post(url, json=payload, headers=headers)
|
51 |
return response.json()["choices"][0]["text"]
|
52 |
|
53 |
+
if st.button("🔍 Toplantıyı Özetle"):
|
54 |
+
if transcript:
|
55 |
+
summary = summarize_text(transcript)
|
56 |
+
st.subheader("📌 Toplantı Özeti:")
|
57 |
+
st.write(summary)
|
|
|
58 |
|
59 |
+
### 📌 3️⃣ Kararları Çıkarma (Hugging Face) ###
|
|
|
|
|
|
|
60 |
def extract_decisions(text):
|
61 |
summary = summary_pipeline(text, max_length=100, min_length=30, do_sample=False)
|
62 |
return summary[0]['summary_text']
|
63 |
|
64 |
+
if st.button("✅ Alınan Kararları Çıkar"):
|
65 |
+
if transcript:
|
66 |
+
decisions = extract_decisions(transcript)
|
67 |
+
st.subheader("📋 Alınan Kararlar:")
|
68 |
+
st.write(decisions)
|
|
|
|
|
|
|
|
|
69 |
|
70 |
### 📌 4️⃣ PDF Raporu Oluşturma ###
|
71 |
def create_pdf(text, filename="meeting_report.pdf"):
|
|
|
75 |
c.save()
|
76 |
return filename
|
77 |
|
78 |
+
if st.button("📄 PDF Raporu Oluştur"):
|
79 |
+
if transcript:
|
80 |
+
pdf_file = create_pdf(transcript)
|
81 |
+
st.success("📄 Rapor oluşturuldu! Aşağıdan indirebilirsiniz.")
|
82 |
+
with open(pdf_file, "rb") as f:
|
83 |
+
st.download_button("📥 Raporu İndir", f, file_name="meeting_report.pdf", mime="application/pdf")
|
|
|
|
|
|
|
84 |
|
85 |
### 📌 5️⃣ E-Posta Gönderme ###
|
86 |
def send_email(pdf_file, recipient_email):
|
|
|
101 |
server.login(email, password)
|
102 |
server.send_message(msg)
|
103 |
|
104 |
+
email_address = st.text_input("📧 E-Posta Adresi:")
|
105 |
+
if st.button("📤 Raporu Gönder"):
|
106 |
+
if email_address:
|
107 |
+
send_email("meeting_report.pdf", email_address)
|
108 |
+
st.success("📤 E-posta başarıyla gönderildi!")
|
109 |
|
|
|
|