Spaces:
Running
Running
merge branch
Browse files- __pycache__/analyze.cpython-310.pyc +0 -0
- __pycache__/transcription.cpython-310.pyc +0 -0
- analyze.py +1 -3
- app.py +50 -0
- templates/feedback.html +46 -1
__pycache__/analyze.cpython-310.pyc
ADDED
Binary file (6.45 kB). View file
|
|
__pycache__/transcription.cpython-310.pyc
CHANGED
Binary files a/__pycache__/transcription.cpython-310.pyc and b/__pycache__/transcription.cpython-310.pyc differ
|
|
analyze.py
CHANGED
@@ -20,9 +20,7 @@ class TextAnalyzer:
|
|
20 |
self.harassment_detected = False # ハラスメントが検出されたかどうか
|
21 |
self.harassment_keywords = [] # 検出されたハラスメントキーワードのリスト
|
22 |
self.deepseek_analysis = {} # DeepSeek API による分析結果を格納する辞書
|
23 |
-
self.api_key =
|
24 |
-
if self.api_key is None:
|
25 |
-
raise ValueError("DEEPSEEK_API_KEY が設定されていません。")
|
26 |
|
27 |
def load_text(self):
|
28 |
"""
|
|
|
20 |
self.harassment_detected = False # ハラスメントが検出されたかどうか
|
21 |
self.harassment_keywords = [] # 検出されたハラスメントキーワードのリスト
|
22 |
self.deepseek_analysis = {} # DeepSeek API による分析結果を格納する辞書
|
23 |
+
self.api_key = None
|
|
|
|
|
24 |
|
25 |
def load_text(self):
|
26 |
"""
|
app.py
CHANGED
@@ -4,11 +4,22 @@ from pydub import AudioSegment # 変換用にpydubをインポート
|
|
4 |
import os
|
5 |
import shutil
|
6 |
from process import AudioProcessor
|
|
|
|
|
|
|
7 |
|
8 |
process=AudioProcessor()
|
|
|
9 |
app = Flask(__name__)
|
10 |
|
11 |
users = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
# トップページ(テンプレート: index.html)
|
14 |
@app.route('/')
|
@@ -31,11 +42,50 @@ def talk_detail():
|
|
31 |
@app.route('/userregister', methods=['GET', 'POST'])
|
32 |
def userregister():
|
33 |
return render_template('userRegister.html')
|
|
|
34 |
#人数確認
|
35 |
@app.route('/confirm', methods=['GET']) # 基本的にGETで取得する想定なので、GETのみに変更
|
36 |
def confirm():
|
37 |
return jsonify({'members': users}), 200
|
38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
|
41 |
# 音声アップロード&解析エンドポイント
|
|
|
4 |
import os
|
5 |
import shutil
|
6 |
from process import AudioProcessor
|
7 |
+
from transcription import TranscriptionMaker
|
8 |
+
from analyze import TextAnalyzer
|
9 |
+
import json
|
10 |
|
11 |
process=AudioProcessor()
|
12 |
+
transcripter = TranscriptionMaker()
|
13 |
app = Flask(__name__)
|
14 |
|
15 |
users = []
|
16 |
+
segments_dir = ""
|
17 |
+
transcription_text=""
|
18 |
+
harassment_keywords = [
|
19 |
+
"バカ", "馬鹿", "アホ", "死ね", "クソ", "うざい",
|
20 |
+
"きもい", "キモい", "ブス", "デブ", "ハゲ",
|
21 |
+
"セクハラ", "パワハラ", "モラハラ"
|
22 |
+
]
|
23 |
|
24 |
# トップページ(テンプレート: index.html)
|
25 |
@app.route('/')
|
|
|
42 |
@app.route('/userregister', methods=['GET', 'POST'])
|
43 |
def userregister():
|
44 |
return render_template('userRegister.html')
|
45 |
+
|
46 |
#人数確認
|
47 |
@app.route('/confirm', methods=['GET']) # 基本的にGETで取得する想定なので、GETのみに変更
|
48 |
def confirm():
|
49 |
return jsonify({'members': users}), 200
|
50 |
|
51 |
+
# 書き起こし作成エンドポイント
|
52 |
+
@app.route('/transcription',methods =['GET','POST'])
|
53 |
+
def transcription():
|
54 |
+
global segments_dir
|
55 |
+
global transcription_text
|
56 |
+
transcription_text = transcripter.create_transcription(segments_dir)
|
57 |
+
return jsonify({'transcription': transcription_text}),200
|
58 |
+
|
59 |
+
# AI分析エンドポイント
|
60 |
+
@app.route('/analyze',methods =['GET','POST'])
|
61 |
+
def analyze():
|
62 |
+
global transcription_text
|
63 |
+
analyzer = TextAnalyzer(transcription_text, harassment_keywords)
|
64 |
+
api_key = os.environ.get("DEEPSEEK")
|
65 |
+
if api_key is None:
|
66 |
+
raise ValueError("DEEPSEEK_API_KEY が設定されていません。")
|
67 |
+
|
68 |
+
results = analyzer.analyze(api_key=api_key)
|
69 |
+
|
70 |
+
print(json.dumps(results, ensure_ascii=False, indent=2))
|
71 |
+
|
72 |
+
if "deepseek_analysis" in results and results["deepseek_analysis"]:
|
73 |
+
deepseek_data = results["deepseek_analysis"]
|
74 |
+
conversation_level = deepseek_data.get("conversationLevel")
|
75 |
+
harassment_present = deepseek_data.get("harassmentPresent")
|
76 |
+
harassment_type = deepseek_data.get("harassmentType")
|
77 |
+
repetition = deepseek_data.get("repetition")
|
78 |
+
pleasantConversation = deepseek_data.get("pleasantConversation")
|
79 |
+
blameOrHarassment = deepseek_data.get("blameOrHarassment")
|
80 |
+
|
81 |
+
print("\n--- DeepSeek 分析結果 ---")
|
82 |
+
print(f"会話レベル: {conversation_level}")
|
83 |
+
print(f"ハラスメントの有無: {harassment_present}")
|
84 |
+
print(f"ハラスメントの種類: {harassment_type}")
|
85 |
+
print(f"繰り返しの程度: {repetition}")
|
86 |
+
print(f"会話の心地よさ: {pleasantConversation}")
|
87 |
+
print(f"非難またはハラスメントの程度: {blameOrHarassment}")
|
88 |
+
return jsonify({"results": results}),200
|
89 |
|
90 |
|
91 |
# 音声アップロード&解析エンドポイント
|
templates/feedback.html
CHANGED
@@ -19,7 +19,52 @@
|
|
19 |
return "素晴らしい";
|
20 |
}
|
21 |
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
const level = 73;
|
24 |
const percentages = [80, 50, 60, 100, 30];
|
25 |
const labels = ["項目1", "項目2", "項目3", "項目4", "項目5"];
|
|
|
19 |
return "素晴らしい";
|
20 |
}
|
21 |
|
22 |
+
async function getTranscription(){
|
23 |
+
try{
|
24 |
+
const response = await fetch('/transcription');
|
25 |
+
if(!response.ok){
|
26 |
+
throw new Error('HTTP error! status: ${response.status}');
|
27 |
+
}
|
28 |
+
const data = await response.json;
|
29 |
+
const results = data.response;
|
30 |
+
}catch(error){
|
31 |
+
console.error("Failed to fetch transcription",error);
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
async function getAnalysis() {
|
36 |
+
try {
|
37 |
+
await getTranscription();
|
38 |
+
|
39 |
+
const response = await fetch('/analyze');
|
40 |
+
if (!response.ok) {
|
41 |
+
throw new Error(`HTTP error! status: ${response.status}`);
|
42 |
+
}
|
43 |
+
|
44 |
+
const data = await response.json();
|
45 |
+
const results = data.results;
|
46 |
+
const analysis = results.deepseek_analysis;
|
47 |
+
|
48 |
+
// 変数に格納
|
49 |
+
const conversationLevel = analysis.conversationLevel;
|
50 |
+
const harassmentPresent = analysis.harassmentPresent;
|
51 |
+
const harassmentType = analysis.harassmentType;
|
52 |
+
const repetition = analysis.repetition;
|
53 |
+
const pleasantConversation = analysis.pleasantConversation;
|
54 |
+
const blameOrHarassment = analysis.blameOrHarassment;
|
55 |
+
|
56 |
+
// コンソールに表示
|
57 |
+
console.log(conversationLevel,harassmentPresent,harassmentType,repetition,pleasantConversation,blameOrHarassment);
|
58 |
+
|
59 |
+
} catch (error) {
|
60 |
+
console.error("Failed to fetch analysis data:", error);
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
|
65 |
+
window.onload = getAnalysis();
|
66 |
+
|
67 |
+
function showSampleData() {
|
68 |
const level = 73;
|
69 |
const percentages = [80, 50, 60, 100, 30];
|
70 |
const labels = ["項目1", "項目2", "項目3", "項目4", "項目5"];
|