fix: auto-fix code issues (cron)
- 修复重复导入/字段 - 修复异常处理 - 修复PEP8格式问题 - 添加类型注解
This commit is contained in:
@@ -4,12 +4,11 @@ InsightFlow Multimodal Processor - Phase 7
|
||||
视频处理模块:提取音频、关键帧、OCR识别
|
||||
"""
|
||||
|
||||
import os
|
||||
import json
|
||||
import uuid
|
||||
import tempfile
|
||||
import os
|
||||
import subprocess
|
||||
from typing import List, Dict, Tuple
|
||||
import tempfile
|
||||
import uuid
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
|
||||
@@ -48,7 +47,7 @@ class VideoFrame:
|
||||
frame_path: str
|
||||
ocr_text: str = ""
|
||||
ocr_confidence: float = 0.0
|
||||
entities_detected: List[Dict] = None
|
||||
entities_detected: list[dict] = None
|
||||
|
||||
def __post_init__(self):
|
||||
if self.entities_detected is None:
|
||||
@@ -72,7 +71,7 @@ class VideoInfo:
|
||||
transcript_id: str = ""
|
||||
status: str = "pending"
|
||||
error_message: str = ""
|
||||
metadata: Dict = None
|
||||
metadata: dict = None
|
||||
|
||||
def __post_init__(self):
|
||||
if self.metadata is None:
|
||||
@@ -85,8 +84,8 @@ class VideoProcessingResult:
|
||||
|
||||
video_id: str
|
||||
audio_path: str
|
||||
frames: List[VideoFrame]
|
||||
ocr_results: List[Dict]
|
||||
frames: list[VideoFrame]
|
||||
ocr_results: list[dict]
|
||||
full_text: str # 整合的文本(音频转录 + OCR文本)
|
||||
success: bool
|
||||
error_message: str = ""
|
||||
@@ -114,7 +113,7 @@ class MultimodalProcessor:
|
||||
os.makedirs(self.frames_dir, exist_ok=True)
|
||||
os.makedirs(self.audio_dir, exist_ok=True)
|
||||
|
||||
def extract_video_info(self, video_path: str) -> Dict:
|
||||
def extract_video_info(self, video_path: str) -> dict:
|
||||
"""
|
||||
提取视频基本信息
|
||||
|
||||
@@ -215,7 +214,7 @@ class MultimodalProcessor:
|
||||
print(f"Error extracting audio: {e}")
|
||||
raise
|
||||
|
||||
def extract_keyframes(self, video_path: str, video_id: str, interval: int = None) -> List[str]:
|
||||
def extract_keyframes(self, video_path: str, video_id: str, interval: int = None) -> list[str]:
|
||||
"""
|
||||
从视频中提取关键帧
|
||||
|
||||
@@ -275,7 +274,7 @@ class MultimodalProcessor:
|
||||
|
||||
return frame_paths
|
||||
|
||||
def perform_ocr(self, image_path: str) -> Tuple[str, float]:
|
||||
def perform_ocr(self, image_path: str) -> tuple[str, float]:
|
||||
"""
|
||||
对图片进行OCR识别
|
||||
|
||||
|
||||
Reference in New Issue
Block a user