mirror of
https://github.com/hwanny1128/HGZero.git
synced 2025-12-06 07:56:24 +00:00
AI 서비스 재시작 스크립트 개선 및 STT 서비스 수정
- AI 서비스 reload 설정 비활성화 (포트 충돌 방지) - start.sh 삭제 및 restart.sh로 대체 - STT 서비스 로깅 및 WebSocket 핸들러 개선 - 회의 안건 섹션 마이그레이션 SQL 추가 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
c9d24ce1af
commit
92c18f71c0
@ -123,6 +123,6 @@ if __name__ == "__main__":
|
||||
"main:app",
|
||||
host=settings.host,
|
||||
port=settings.port,
|
||||
reload=True, # 개발 모드
|
||||
reload=False, # reload=True는 포트 충돌 발생 가능
|
||||
log_level=settings.log_level.lower()
|
||||
)
|
||||
|
||||
115
ai-python/restart.sh
Executable file
115
ai-python/restart.sh
Executable file
@ -0,0 +1,115 @@
|
||||
#!/bin/bash
|
||||
|
||||
# AI Python 서비스 재시작 스크립트
|
||||
# 8086 포트로 깔끔하게 재시작
|
||||
|
||||
echo "=================================="
|
||||
echo "AI Python 서비스 재시작"
|
||||
echo "=================================="
|
||||
|
||||
# 1. 기존 프로세스 종료
|
||||
echo "1️⃣ 기존 프로세스 정리 중..."
|
||||
pkill -9 -f "python.*main.py" 2>/dev/null
|
||||
pkill -9 -f "uvicorn.*8086" 2>/dev/null
|
||||
pkill -9 -f "uvicorn.*8087" 2>/dev/null
|
||||
|
||||
# 잠시 대기 (포트 해제 대기)
|
||||
sleep 2
|
||||
|
||||
# 2. 포트 확인
|
||||
echo "2️⃣ 포트 상태 확인..."
|
||||
if lsof -i:8086 > /dev/null 2>&1; then
|
||||
echo " ⚠️ 8086 포트가 아직 사용 중입니다."
|
||||
echo " 강제 종료 시도..."
|
||||
PID=$(lsof -ti:8086)
|
||||
if [ ! -z "$PID" ]; then
|
||||
kill -9 $PID
|
||||
sleep 2
|
||||
fi
|
||||
fi
|
||||
|
||||
if lsof -i:8086 > /dev/null 2>&1; then
|
||||
echo " ❌ 8086 포트를 해제할 수 없습니다."
|
||||
echo " 시스템 재부팅 후 다시 시도하거나,"
|
||||
echo " 다른 포트를 사용하세요."
|
||||
exit 1
|
||||
else
|
||||
echo " ✅ 8086 포트 사용 가능"
|
||||
fi
|
||||
|
||||
# 3. 가상환경 활성화
|
||||
echo "3️⃣ 가상환경 활성화..."
|
||||
if [ ! -d "venv" ]; then
|
||||
echo " ❌ 가상환경이 없습니다. venv 디렉토리를 생성하세요."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
source venv/bin/activate
|
||||
echo " ✅ 가상환경 활성화 완료"
|
||||
|
||||
# 4. 로그 디렉토리 확인
|
||||
mkdir -p ../logs
|
||||
|
||||
# 5. 서비스 시작
|
||||
echo "4️⃣ AI Python 서비스 시작 (포트: 8086)..."
|
||||
nohup python3 main.py > ../logs/ai-python.log 2>&1 &
|
||||
PID=$!
|
||||
|
||||
echo " PID: $PID"
|
||||
echo " 로그: ../logs/ai-python.log"
|
||||
|
||||
# 6. 시작 대기
|
||||
echo "5️⃣ 서비스 시작 대기 (7초)..."
|
||||
sleep 7
|
||||
|
||||
# 7. 상태 확인
|
||||
echo "6️⃣ 서비스 상태 확인..."
|
||||
|
||||
# 프로세스 확인
|
||||
if ps -p $PID > /dev/null; then
|
||||
echo " ✅ 프로세스 실행 중 (PID: $PID)"
|
||||
else
|
||||
echo " ❌ 프로세스 종료됨"
|
||||
echo " 로그 확인:"
|
||||
tail -20 ../logs/ai-python.log
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 포트 확인
|
||||
if lsof -i:8086 > /dev/null 2>&1; then
|
||||
echo " ✅ 8086 포트 리스닝 중"
|
||||
else
|
||||
echo " ⚠️ 8086 포트 아직 준비 중..."
|
||||
fi
|
||||
|
||||
# Health 체크
|
||||
echo "7️⃣ Health Check..."
|
||||
sleep 2
|
||||
HEALTH=$(curl -s http://localhost:8086/health 2>/dev/null)
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo " ✅ Health Check 성공"
|
||||
echo " $HEALTH"
|
||||
else
|
||||
echo " ⚠️ Health Check 실패 (서버가 아직 시작 중일 수 있습니다)"
|
||||
echo ""
|
||||
echo " 최근 로그:"
|
||||
tail -10 ../logs/ai-python.log
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "=================================="
|
||||
echo "✅ AI Python 서비스 시작 완료"
|
||||
echo "=================================="
|
||||
echo "📊 서비스 정보:"
|
||||
echo " - PID: $PID"
|
||||
echo " - 포트: 8086"
|
||||
echo " - 로그: tail -f ../logs/ai-python.log"
|
||||
echo ""
|
||||
echo "📡 엔드포인트:"
|
||||
echo " - Health: http://localhost:8086/health"
|
||||
echo " - Root: http://localhost:8086/"
|
||||
echo " - Swagger: http://localhost:8086/swagger-ui.html"
|
||||
echo ""
|
||||
echo "🛑 서비스 중지: pkill -f 'python.*main.py'"
|
||||
echo "=================================="
|
||||
@ -1,35 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# AI Service (Python) 시작 스크립트
|
||||
|
||||
echo "======================================"
|
||||
echo "AI Service (Python) 시작"
|
||||
echo "======================================"
|
||||
|
||||
# 가상환경 활성화 (선택사항)
|
||||
# source venv/bin/activate
|
||||
|
||||
# 의존성 설치 확인
|
||||
if [ ! -d "venv" ]; then
|
||||
echo "가상환경이 없습니다. 생성 중..."
|
||||
python3 -m venv venv
|
||||
source venv/bin/activate
|
||||
pip install -r requirements.txt
|
||||
else
|
||||
source venv/bin/activate
|
||||
fi
|
||||
|
||||
# .env 파일 확인
|
||||
if [ ! -f ".env" ]; then
|
||||
echo ".env 파일이 없습니다. .env.example을 복사합니다."
|
||||
cp .env.example .env
|
||||
echo "⚠️ .env 파일에 실제 API 키를 설정해주세요."
|
||||
fi
|
||||
|
||||
# FastAPI 서버 시작
|
||||
echo "======================================"
|
||||
echo "FastAPI 서버 시작 중..."
|
||||
echo "Port: 8086"
|
||||
echo "======================================"
|
||||
|
||||
python3 main.py
|
||||
@ -650,7 +650,7 @@ code + .copy-button {
|
||||
<script type="text/javascript">
|
||||
function configurationCacheProblems() { return (
|
||||
// begin-report-data
|
||||
{"diagnostics":[{"locations":[{"path":"/Users/daewoong/home/workspace/HGZero/common/src/main/java/com/unicorn/hgzero/common/security/JwtTokenProvider.java"},{"taskPath":":common:compileJava"}],"problem":[{"text":"/Users/daewoong/home/workspace/HGZero/common/src/main/java/com/unicorn/hgzero/common/security/JwtTokenProvider.java uses or overrides a deprecated API."}],"severity":"ADVICE","problemDetails":[{"text":"Note: /Users/daewoong/home/workspace/HGZero/common/src/main/java/com/unicorn/hgzero/common/security/JwtTokenProvider.java uses or overrides a deprecated API."}],"contextualLabel":"/Users/daewoong/home/workspace/HGZero/common/src/main/java/com/unicorn/hgzero/common/security/JwtTokenProvider.java uses or overrides a deprecated API.","problemId":[{"name":"java","displayName":"Java compilation"},{"name":"compilation","displayName":"Compilation"},{"name":"compiler.note.deprecated.filename","displayName":"/Users/daewoong/home/workspace/HGZero/common/src/main/java/com/unicorn/hgzero/common/security/JwtTokenProvider.java uses or overrides a deprecated API."}]},{"locations":[{"path":"/Users/daewoong/home/workspace/HGZero/common/src/main/java/com/unicorn/hgzero/common/security/JwtTokenProvider.java"},{"taskPath":":common:compileJava"}],"problem":[{"text":"Recompile with -Xlint:deprecation for details."}],"severity":"ADVICE","problemDetails":[{"text":"Note: Recompile with -Xlint:deprecation for details."}],"contextualLabel":"Recompile with -Xlint:deprecation for details.","problemId":[{"name":"java","displayName":"Java compilation"},{"name":"compilation","displayName":"Compilation"},{"name":"compiler.note.deprecated.recompile","displayName":"Recompile with -Xlint:deprecation for details."}]},{"locations":[{"path":"/Users/daewoong/home/workspace/HGZero/user/src/main/java/com/unicorn/hgzero/user/service/UserServiceImpl.java"},{"taskPath":":user:compileJava"}],"problem":[{"text":"/Users/daewoong/home/workspace/HGZero/user/src/main/java/com/unicorn/hgzero/user/service/UserServiceImpl.java uses or overrides a deprecated API."}],"severity":"ADVICE","problemDetails":[{"text":"Note: /Users/daewoong/home/workspace/HGZero/user/src/main/java/com/unicorn/hgzero/user/service/UserServiceImpl.java uses or overrides a deprecated API."}],"contextualLabel":"/Users/daewoong/home/workspace/HGZero/user/src/main/java/com/unicorn/hgzero/user/service/UserServiceImpl.java uses or overrides a deprecated API.","problemId":[{"name":"java","displayName":"Java compilation"},{"name":"compilation","displayName":"Compilation"},{"name":"compiler.note.deprecated.filename","displayName":"/Users/daewoong/home/workspace/HGZero/user/src/main/java/com/unicorn/hgzero/user/service/UserServiceImpl.java uses or overrides a deprecated API."}]},{"locations":[{"path":"/Users/daewoong/home/workspace/HGZero/user/src/main/java/com/unicorn/hgzero/user/service/UserServiceImpl.java"},{"taskPath":":user:compileJava"}],"problem":[{"text":"Recompile with -Xlint:deprecation for details."}],"severity":"ADVICE","problemDetails":[{"text":"Note: Recompile with -Xlint:deprecation for details."}],"contextualLabel":"Recompile with -Xlint:deprecation for details.","problemId":[{"name":"java","displayName":"Java compilation"},{"name":"compilation","displayName":"Compilation"},{"name":"compiler.note.deprecated.recompile","displayName":"Recompile with -Xlint:deprecation for details."}]},{"locations":[{"path":"/Users/daewoong/home/workspace/HGZero/meeting/src/main/java/com/unicorn/hgzero/meeting/infra/dto/request/InviteParticipantRequest.java"},{"taskPath":":meeting:compileJava"}],"problem":[{"text":"Some input files use or override a deprecated API."}],"severity":"ADVICE","problemDetails":[{"text":"Note: Some input files use or override a deprecated API."}],"contextualLabel":"Some input files use or override a deprecated API.","problemId":[{"name":"java","displayName":"Java compilation"},{"name":"compilation","displayName":"Compilation"},{"name":"compiler.note.deprecated.plural","displayName":"Some input files use or override a deprecated API."}]},{"locations":[{"path":"/Users/daewoong/home/workspace/HGZero/meeting/src/main/java/com/unicorn/hgzero/meeting/infra/dto/request/InviteParticipantRequest.java"},{"taskPath":":meeting:compileJava"}],"problem":[{"text":"Recompile with -Xlint:deprecation for details."}],"severity":"ADVICE","problemDetails":[{"text":"Note: Recompile with -Xlint:deprecation for details."}],"contextualLabel":"Recompile with -Xlint:deprecation for details.","problemId":[{"name":"java","displayName":"Java compilation"},{"name":"compilation","displayName":"Compilation"},{"name":"compiler.note.deprecated.recompile","displayName":"Recompile with -Xlint:deprecation for details."}]}],"problemsReport":{"totalProblemCount":6,"buildName":"hgzero","requestedTasks":"clean bootJar","documentationLink":"https://docs.gradle.org/8.14/userguide/reporting_problems.html","documentationLinkCaption":"Problem report","summaries":[]}}
|
||||
{"diagnostics":[{"locations":[{"path":"/Users/jominseo/HGZero/stt/src/main/java/com/unicorn/hgzero/stt/controller/AudioWebSocketHandler.java"},{"taskPath":":stt:compileJava"}],"problem":[{"text":"/Users/jominseo/HGZero/stt/src/main/java/com/unicorn/hgzero/stt/controller/AudioWebSocketHandler.java uses unchecked or unsafe operations."}],"severity":"ADVICE","problemDetails":[{"text":"Note: /Users/jominseo/HGZero/stt/src/main/java/com/unicorn/hgzero/stt/controller/AudioWebSocketHandler.java uses unchecked or unsafe operations."}],"contextualLabel":"/Users/jominseo/HGZero/stt/src/main/java/com/unicorn/hgzero/stt/controller/AudioWebSocketHandler.java uses unchecked or unsafe operations.","problemId":[{"name":"java","displayName":"Java compilation"},{"name":"compilation","displayName":"Compilation"},{"name":"compiler.note.unchecked.filename","displayName":"/Users/jominseo/HGZero/stt/src/main/java/com/unicorn/hgzero/stt/controller/AudioWebSocketHandler.java uses unchecked or unsafe operations."}]},{"locations":[{"path":"/Users/jominseo/HGZero/stt/src/main/java/com/unicorn/hgzero/stt/controller/AudioWebSocketHandler.java"},{"taskPath":":stt:compileJava"}],"problem":[{"text":"Recompile with -Xlint:unchecked for details."}],"severity":"ADVICE","problemDetails":[{"text":"Note: Recompile with -Xlint:unchecked for details."}],"contextualLabel":"Recompile with -Xlint:unchecked for details.","problemId":[{"name":"java","displayName":"Java compilation"},{"name":"compilation","displayName":"Compilation"},{"name":"compiler.note.unchecked.recompile","displayName":"Recompile with -Xlint:unchecked for details."}]},{"locations":[{"taskPath":":stt:test"}],"problem":[{"text":"The automatic loading of test framework implementation dependencies has been deprecated."}],"severity":"WARNING","problemDetails":[{"text":"This is scheduled to be removed in Gradle 9.0."}],"contextualLabel":"The automatic loading of test framework implementation dependencies has been deprecated.","documentationLink":"https://docs.gradle.org/8.14/userguide/upgrading_version_8.html#test_framework_implementation_dependencies","problemId":[{"name":"deprecation","displayName":"Deprecation"},{"name":"the-automatic-loading-of-test-framework-implementation-dependencies","displayName":"The automatic loading of test framework implementation dependencies has been deprecated."}],"solutions":[[{"text":"Declare the desired test framework directly on the test suite or explicitly declare the test framework implementation dependencies on the test's runtime classpath."}]]}],"problemsReport":{"totalProblemCount":3,"buildName":"hgzero","requestedTasks":"build","documentationLink":"https://docs.gradle.org/8.14/userguide/reporting_problems.html","documentationLinkCaption":"Problem report","summaries":[]}}
|
||||
// end-report-data
|
||||
);}
|
||||
</script>
|
||||
|
||||
142
meeting/migrate-agenda-sections.sql
Normal file
142
meeting/migrate-agenda-sections.sql
Normal file
@ -0,0 +1,142 @@
|
||||
-- ====================================================================
|
||||
-- agenda_sections 테이블 마이그레이션 스크립트
|
||||
--
|
||||
-- 목적:
|
||||
-- 1. agenda_number: varchar(50) → integer 변환
|
||||
-- 2. decisions, pending_items, todos: text → json 변환
|
||||
-- 3. opinions 컬럼 삭제 (서비스에서 미사용)
|
||||
--
|
||||
-- 실행 전 필수 작업:
|
||||
-- 1. 데이터베이스 백업 (pg_dump)
|
||||
-- 2. 테스트 환경에서 먼저 실행 및 검증
|
||||
-- ====================================================================
|
||||
|
||||
-- 트랜잭션 시작
|
||||
BEGIN;
|
||||
|
||||
-- ====================================================================
|
||||
-- 1단계: 백업 테이블 생성 (롤백용)
|
||||
-- ====================================================================
|
||||
CREATE TABLE IF NOT EXISTS agenda_sections_backup AS
|
||||
SELECT * FROM agenda_sections;
|
||||
|
||||
SELECT '✓ 백업 테이블 생성 완료: agenda_sections_backup' AS status;
|
||||
|
||||
-- ====================================================================
|
||||
-- 2단계: agenda_number 컬럼 타입 변경 (varchar → integer)
|
||||
-- ====================================================================
|
||||
-- 데이터 검증: 숫자가 아닌 값이 있는지 확인
|
||||
DO $$
|
||||
DECLARE
|
||||
invalid_count INTEGER;
|
||||
BEGIN
|
||||
SELECT COUNT(*) INTO invalid_count
|
||||
FROM agenda_sections
|
||||
WHERE agenda_number !~ '^[0-9]+$';
|
||||
|
||||
IF invalid_count > 0 THEN
|
||||
RAISE EXCEPTION '숫자가 아닌 agenda_number 값이 % 건 발견됨. 데이터 정리 필요.', invalid_count;
|
||||
END IF;
|
||||
|
||||
RAISE NOTICE '✓ agenda_number 데이터 검증 완료 (모두 숫자)';
|
||||
END $$;
|
||||
|
||||
-- 타입 변경 실행
|
||||
ALTER TABLE agenda_sections
|
||||
ALTER COLUMN agenda_number TYPE integer
|
||||
USING agenda_number::integer;
|
||||
|
||||
SELECT '✓ agenda_number 타입 변경 완료: varchar(50) → integer' AS status;
|
||||
|
||||
-- ====================================================================
|
||||
-- 3단계: JSON 컬럼 타입 변경 (text → json)
|
||||
-- ====================================================================
|
||||
|
||||
-- 3-1. decisions 컬럼 변경
|
||||
ALTER TABLE agenda_sections
|
||||
ALTER COLUMN decisions TYPE json
|
||||
USING CASE
|
||||
WHEN decisions IS NULL OR decisions = '' THEN NULL
|
||||
ELSE decisions::json
|
||||
END;
|
||||
|
||||
SELECT '✓ decisions 타입 변경 완료: text → json' AS status;
|
||||
|
||||
-- 3-2. pending_items 컬럼 변경
|
||||
ALTER TABLE agenda_sections
|
||||
ALTER COLUMN pending_items TYPE json
|
||||
USING CASE
|
||||
WHEN pending_items IS NULL OR pending_items = '' THEN NULL
|
||||
ELSE pending_items::json
|
||||
END;
|
||||
|
||||
SELECT '✓ pending_items 타입 변경 완료: text → json' AS status;
|
||||
|
||||
-- 3-3. todos 컬럼 변경
|
||||
ALTER TABLE agenda_sections
|
||||
ALTER COLUMN todos TYPE json
|
||||
USING CASE
|
||||
WHEN todos IS NULL OR todos = '' THEN NULL
|
||||
ELSE todos::json
|
||||
END;
|
||||
|
||||
SELECT '✓ todos 타입 변경 완료: text → json' AS status;
|
||||
|
||||
-- ====================================================================
|
||||
-- 4단계: opinions 컬럼 삭제 (서비스에서 미사용)
|
||||
-- ====================================================================
|
||||
ALTER TABLE agenda_sections
|
||||
DROP COLUMN IF EXISTS opinions;
|
||||
|
||||
SELECT '✓ opinions 컬럼 삭제 완료' AS status;
|
||||
|
||||
-- ====================================================================
|
||||
-- 5단계: 변경 사항 검증
|
||||
-- ====================================================================
|
||||
DO $$
|
||||
DECLARE
|
||||
rec RECORD;
|
||||
BEGIN
|
||||
-- 테이블 구조 확인
|
||||
SELECT
|
||||
column_name,
|
||||
data_type,
|
||||
character_maximum_length,
|
||||
is_nullable
|
||||
INTO rec
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = 'agenda_sections'
|
||||
AND column_name = 'agenda_number';
|
||||
|
||||
RAISE NOTICE '========================================';
|
||||
RAISE NOTICE '✓ 마이그레이션 검증 결과';
|
||||
RAISE NOTICE '========================================';
|
||||
RAISE NOTICE 'agenda_number 타입: %', rec.data_type;
|
||||
|
||||
-- 데이터 건수 확인
|
||||
RAISE NOTICE '원본 데이터 건수: %', (SELECT COUNT(*) FROM agenda_sections_backup);
|
||||
RAISE NOTICE '마이그레이션 후 건수: %', (SELECT COUNT(*) FROM agenda_sections);
|
||||
RAISE NOTICE '========================================';
|
||||
END $$;
|
||||
|
||||
-- ====================================================================
|
||||
-- 커밋 또는 롤백 선택
|
||||
-- ====================================================================
|
||||
-- 문제가 없으면 COMMIT, 문제가 있으면 ROLLBACK 실행
|
||||
|
||||
-- 성공 시: COMMIT;
|
||||
-- 실패 시: ROLLBACK;
|
||||
|
||||
COMMIT;
|
||||
|
||||
SELECT '
|
||||
====================================================================
|
||||
✓ 마이그레이션 완료!
|
||||
|
||||
다음 작업:
|
||||
1. 애플리케이션 재시작
|
||||
2. 기능 테스트 수행
|
||||
3. 문제 없으면 백업 테이블 삭제:
|
||||
DROP TABLE agenda_sections_backup;
|
||||
====================================================================
|
||||
' AS next_steps;
|
||||
96229
stt/logs/stt.log
96229
stt/logs/stt.log
File diff suppressed because it is too large
Load Diff
@ -32,6 +32,9 @@ public class AzureSpeechService {
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
try {
|
||||
log.info("Azure Speech Service 초기화 시작 - subscriptionKey: {}, region: {}",
|
||||
subscriptionKey != null && !subscriptionKey.trim().isEmpty() ? "설정됨" : "미설정", region);
|
||||
|
||||
if (subscriptionKey == null || subscriptionKey.trim().isEmpty()) {
|
||||
log.warn("Azure Speech Subscription Key 미설정 - 시뮬레이션 모드로 실행");
|
||||
return;
|
||||
|
||||
423
stt/test-websocket.html
Normal file
423
stt/test-websocket.html
Normal file
@ -0,0 +1,423 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ko">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>STT WebSocket 테스트</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
.container {
|
||||
background: white;
|
||||
border-radius: 8px;
|
||||
padding: 20px;
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
h2 {
|
||||
color: #333;
|
||||
border-bottom: 2px solid #4CAF50;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
.controls {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-bottom: 20px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
button {
|
||||
padding: 10px 20px;
|
||||
font-size: 14px;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.3s;
|
||||
}
|
||||
button:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.btn-connect {
|
||||
background-color: #4CAF50;
|
||||
color: white;
|
||||
}
|
||||
.btn-connect:hover:not(:disabled) {
|
||||
background-color: #45a049;
|
||||
}
|
||||
.btn-disconnect {
|
||||
background-color: #f44336;
|
||||
color: white;
|
||||
}
|
||||
.btn-disconnect:hover:not(:disabled) {
|
||||
background-color: #da190b;
|
||||
}
|
||||
.btn-record {
|
||||
background-color: #2196F3;
|
||||
color: white;
|
||||
}
|
||||
.btn-record:hover:not(:disabled) {
|
||||
background-color: #0b7dda;
|
||||
}
|
||||
.btn-stop {
|
||||
background-color: #ff9800;
|
||||
color: white;
|
||||
}
|
||||
.btn-stop:hover:not(:disabled) {
|
||||
background-color: #e68900;
|
||||
}
|
||||
.btn-clear {
|
||||
background-color: #9E9E9E;
|
||||
color: white;
|
||||
}
|
||||
.status {
|
||||
padding: 10px;
|
||||
border-radius: 4px;
|
||||
margin-bottom: 10px;
|
||||
font-weight: bold;
|
||||
}
|
||||
.status-connected {
|
||||
background-color: #dff0d8;
|
||||
color: #3c763d;
|
||||
}
|
||||
.status-disconnected {
|
||||
background-color: #f2dede;
|
||||
color: #a94442;
|
||||
}
|
||||
.status-recording {
|
||||
background-color: #d9edf7;
|
||||
color: #31708f;
|
||||
}
|
||||
.log-container {
|
||||
background-color: #f9f9f9;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
padding: 10px;
|
||||
max-height: 300px;
|
||||
overflow-y: auto;
|
||||
font-family: 'Courier New', monospace;
|
||||
font-size: 12px;
|
||||
}
|
||||
.log-entry {
|
||||
padding: 5px;
|
||||
margin: 2px 0;
|
||||
border-radius: 3px;
|
||||
}
|
||||
.log-info {
|
||||
background-color: #e7f4ff;
|
||||
}
|
||||
.log-success {
|
||||
background-color: #d4edda;
|
||||
}
|
||||
.log-error {
|
||||
background-color: #f8d7da;
|
||||
color: #721c24;
|
||||
}
|
||||
.log-data {
|
||||
background-color: #fff3cd;
|
||||
}
|
||||
.transcript {
|
||||
padding: 15px;
|
||||
background-color: #f0f8ff;
|
||||
border-left: 4px solid #2196F3;
|
||||
margin: 10px 0;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.transcript-text {
|
||||
font-size: 16px;
|
||||
color: #333;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.transcript-meta {
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
}
|
||||
input {
|
||||
padding: 8px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
font-size: 14px;
|
||||
}
|
||||
.stats {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
gap: 10px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
.stat-box {
|
||||
background-color: #f9f9f9;
|
||||
padding: 10px;
|
||||
border-radius: 4px;
|
||||
text-align: center;
|
||||
}
|
||||
.stat-label {
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
}
|
||||
.stat-value {
|
||||
font-size: 24px;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>🎤 STT WebSocket 테스트 도구</h1>
|
||||
|
||||
<div class="container">
|
||||
<h2>연결 설정</h2>
|
||||
<div class="controls">
|
||||
<input type="text" id="wsUrl" value="ws://localhost:8084/ws/audio" placeholder="WebSocket URL" style="width: 300px;">
|
||||
<input type="text" id="meetingId" value="test-mtg-001" placeholder="Meeting ID" style="width: 200px;">
|
||||
<button class="btn-connect" id="connectBtn" onclick="connect()">연결</button>
|
||||
<button class="btn-disconnect" id="disconnectBtn" onclick="disconnect()" disabled>연결 해제</button>
|
||||
</div>
|
||||
<div id="status" class="status status-disconnected">연결 안 됨</div>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<h2>녹음 제어</h2>
|
||||
<div class="controls">
|
||||
<button class="btn-record" id="recordBtn" onclick="startRecording()" disabled>녹음 시작</button>
|
||||
<button class="btn-stop" id="stopBtn" onclick="stopRecording()" disabled>녹음 중지</button>
|
||||
<button class="btn-clear" onclick="clearLogs()">로그 지우기</button>
|
||||
</div>
|
||||
<div class="stats">
|
||||
<div class="stat-box">
|
||||
<div class="stat-label">전송된 청크</div>
|
||||
<div class="stat-value" id="chunkCount">0</div>
|
||||
</div>
|
||||
<div class="stat-box">
|
||||
<div class="stat-label">전송 데이터</div>
|
||||
<div class="stat-value" id="dataSize">0 KB</div>
|
||||
</div>
|
||||
<div class="stat-box">
|
||||
<div class="stat-label">녹음 시간</div>
|
||||
<div class="stat-value" id="recordTime">0초</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<h2>STT 결과</h2>
|
||||
<div id="transcripts"></div>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<h2>통신 로그</h2>
|
||||
<div class="log-container" id="logContainer"></div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
let ws = null;
|
||||
let mediaRecorder = null;
|
||||
let audioStream = null;
|
||||
let chunkCounter = 0;
|
||||
let totalDataSize = 0;
|
||||
let recordStartTime = null;
|
||||
let recordTimer = null;
|
||||
|
||||
function addLog(message, type = 'info') {
|
||||
const logContainer = document.getElementById('logContainer');
|
||||
const timestamp = new Date().toLocaleTimeString('ko-KR', { hour12: false });
|
||||
const logEntry = document.createElement('div');
|
||||
logEntry.className = `log-entry log-${type}`;
|
||||
logEntry.textContent = `[${timestamp}] ${message}`;
|
||||
logContainer.appendChild(logEntry);
|
||||
logContainer.scrollTop = logContainer.scrollHeight;
|
||||
}
|
||||
|
||||
function updateStatus(message, isConnected, isRecording = false) {
|
||||
const statusEl = document.getElementById('status');
|
||||
statusEl.textContent = message;
|
||||
statusEl.className = 'status ' +
|
||||
(isRecording ? 'status-recording' : (isConnected ? 'status-connected' : 'status-disconnected'));
|
||||
}
|
||||
|
||||
function updateStats() {
|
||||
if (recordStartTime) {
|
||||
const elapsed = Math.floor((Date.now() - recordStartTime) / 1000);
|
||||
document.getElementById('recordTime').textContent = `${elapsed}초`;
|
||||
}
|
||||
}
|
||||
|
||||
function connect() {
|
||||
const wsUrl = document.getElementById('wsUrl').value;
|
||||
const meetingId = document.getElementById('meetingId').value;
|
||||
|
||||
addLog(`WebSocket 연결 시도: ${wsUrl}`, 'info');
|
||||
|
||||
ws = new WebSocket(wsUrl);
|
||||
|
||||
ws.onopen = () => {
|
||||
addLog('WebSocket 연결 성공!', 'success');
|
||||
updateStatus('연결됨', true);
|
||||
|
||||
// 녹음 시작 메시지 전송
|
||||
const startMsg = {
|
||||
type: 'start',
|
||||
meetingId: meetingId
|
||||
};
|
||||
ws.send(JSON.stringify(startMsg));
|
||||
addLog(`START 메시지 전송: ${JSON.stringify(startMsg)}`, 'data');
|
||||
|
||||
document.getElementById('connectBtn').disabled = true;
|
||||
document.getElementById('disconnectBtn').disabled = false;
|
||||
document.getElementById('recordBtn').disabled = false;
|
||||
};
|
||||
|
||||
ws.onmessage = (event) => {
|
||||
try {
|
||||
const data = JSON.parse(event.data);
|
||||
addLog(`메시지 수신: ${JSON.stringify(data)}`, 'success');
|
||||
|
||||
if (data.transcript) {
|
||||
// STT 결과 표시
|
||||
const transcriptsEl = document.getElementById('transcripts');
|
||||
const transcriptDiv = document.createElement('div');
|
||||
transcriptDiv.className = 'transcript';
|
||||
transcriptDiv.innerHTML = `
|
||||
<div class="transcript-text">${data.transcript}</div>
|
||||
<div class="transcript-meta">
|
||||
신뢰도: ${(data.confidence * 100).toFixed(1)}% |
|
||||
화자: ${data.speaker} |
|
||||
시간: ${new Date(data.timestamp).toLocaleTimeString('ko-KR')}
|
||||
</div>
|
||||
`;
|
||||
transcriptsEl.insertBefore(transcriptDiv, transcriptsEl.firstChild);
|
||||
}
|
||||
} catch (e) {
|
||||
addLog(`메시지 파싱 오류: ${e.message}`, 'error');
|
||||
}
|
||||
};
|
||||
|
||||
ws.onerror = (error) => {
|
||||
addLog(`WebSocket 오류: ${error}`, 'error');
|
||||
};
|
||||
|
||||
ws.onclose = () => {
|
||||
addLog('WebSocket 연결 종료', 'info');
|
||||
updateStatus('연결 안 됨', false);
|
||||
document.getElementById('connectBtn').disabled = false;
|
||||
document.getElementById('disconnectBtn').disabled = true;
|
||||
document.getElementById('recordBtn').disabled = true;
|
||||
document.getElementById('stopBtn').disabled = true;
|
||||
};
|
||||
}
|
||||
|
||||
function disconnect() {
|
||||
if (ws) {
|
||||
const stopMsg = { type: 'stop' };
|
||||
ws.send(JSON.stringify(stopMsg));
|
||||
addLog(`STOP 메시지 전송: ${JSON.stringify(stopMsg)}`, 'data');
|
||||
ws.close();
|
||||
ws = null;
|
||||
}
|
||||
if (mediaRecorder && mediaRecorder.state === 'recording') {
|
||||
stopRecording();
|
||||
}
|
||||
}
|
||||
|
||||
async function startRecording() {
|
||||
try {
|
||||
audioStream = await navigator.mediaDevices.getUserMedia({
|
||||
audio: {
|
||||
channelCount: 1,
|
||||
sampleRate: 16000,
|
||||
echoCancellation: true,
|
||||
noiseSuppression: true
|
||||
}
|
||||
});
|
||||
|
||||
addLog('마이크 접근 허용됨', 'success');
|
||||
|
||||
mediaRecorder = new MediaRecorder(audioStream, {
|
||||
mimeType: 'audio/webm;codecs=opus',
|
||||
audioBitsPerSecond: 16000
|
||||
});
|
||||
|
||||
chunkCounter = 0;
|
||||
totalDataSize = 0;
|
||||
recordStartTime = Date.now();
|
||||
recordTimer = setInterval(updateStats, 1000);
|
||||
|
||||
mediaRecorder.ondataavailable = (event) => {
|
||||
if (event.data.size > 0 && ws && ws.readyState === WebSocket.OPEN) {
|
||||
const reader = new FileReader();
|
||||
reader.readAsDataURL(event.data);
|
||||
reader.onloadend = () => {
|
||||
const base64Audio = reader.result.split(',')[1];
|
||||
const meetingId = document.getElementById('meetingId').value;
|
||||
|
||||
const chunkMsg = {
|
||||
type: 'chunk',
|
||||
meetingId: meetingId,
|
||||
audioData: base64Audio,
|
||||
timestamp: Date.now(),
|
||||
chunkIndex: chunkCounter++,
|
||||
format: 'audio/webm',
|
||||
sampleRate: 16000
|
||||
};
|
||||
|
||||
ws.send(JSON.stringify(chunkMsg));
|
||||
|
||||
totalDataSize += event.data.size;
|
||||
document.getElementById('chunkCount').textContent = chunkCounter;
|
||||
document.getElementById('dataSize').textContent = (totalDataSize / 1024).toFixed(2) + ' KB';
|
||||
|
||||
addLog(`청크 #${chunkCounter} 전송: ${(event.data.size / 1024).toFixed(2)} KB`, 'data');
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
mediaRecorder.start(1000); // 1초마다 청크 전송
|
||||
addLog('녹음 시작 (1초 간격)', 'success');
|
||||
updateStatus('녹음 중', true, true);
|
||||
|
||||
document.getElementById('recordBtn').disabled = true;
|
||||
document.getElementById('stopBtn').disabled = false;
|
||||
|
||||
} catch (error) {
|
||||
addLog(`마이크 접근 실패: ${error.message}`, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
function stopRecording() {
|
||||
if (mediaRecorder && mediaRecorder.state === 'recording') {
|
||||
mediaRecorder.stop();
|
||||
mediaRecorder = null;
|
||||
addLog('녹음 중지', 'info');
|
||||
}
|
||||
|
||||
if (audioStream) {
|
||||
audioStream.getTracks().forEach(track => track.stop());
|
||||
audioStream = null;
|
||||
}
|
||||
|
||||
if (recordTimer) {
|
||||
clearInterval(recordTimer);
|
||||
recordTimer = null;
|
||||
}
|
||||
|
||||
updateStatus('연결됨', true, false);
|
||||
document.getElementById('recordBtn').disabled = false;
|
||||
document.getElementById('stopBtn').disabled = true;
|
||||
}
|
||||
|
||||
function clearLogs() {
|
||||
document.getElementById('logContainer').innerHTML = '';
|
||||
document.getElementById('transcripts').innerHTML = '';
|
||||
chunkCounter = 0;
|
||||
totalDataSize = 0;
|
||||
recordStartTime = null;
|
||||
document.getElementById('chunkCount').textContent = '0';
|
||||
document.getElementById('dataSize').textContent = '0 KB';
|
||||
document.getElementById('recordTime').textContent = '0초';
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
x
Reference in New Issue
Block a user