feat: Implement AI script generation for audiobook projects
This commit is contained in:
@@ -421,6 +421,7 @@ def create_audiobook_project(
|
||||
source_text: Optional[str] = None,
|
||||
source_path: Optional[str] = None,
|
||||
llm_model: Optional[str] = None,
|
||||
script_config: Optional[Dict[str, Any]] = None,
|
||||
) -> AudiobookProject:
|
||||
project = AudiobookProject(
|
||||
user_id=user_id,
|
||||
@@ -429,6 +430,7 @@ def create_audiobook_project(
|
||||
source_text=source_text,
|
||||
source_path=source_path,
|
||||
llm_model=llm_model,
|
||||
script_config=script_config,
|
||||
status="pending",
|
||||
)
|
||||
db.add(project)
|
||||
@@ -501,6 +503,13 @@ def get_audiobook_chapter(db: Session, chapter_id: int) -> Optional[AudiobookCha
|
||||
return db.query(AudiobookChapter).filter(AudiobookChapter.id == chapter_id).first()
|
||||
|
||||
|
||||
def get_audiobook_chapter_by_index(db: Session, project_id: int, chapter_index: int) -> Optional[AudiobookChapter]:
|
||||
return db.query(AudiobookChapter).filter(
|
||||
AudiobookChapter.project_id == project_id,
|
||||
AudiobookChapter.chapter_index == chapter_index,
|
||||
).first()
|
||||
|
||||
|
||||
def list_audiobook_chapters(db: Session, project_id: int) -> List[AudiobookChapter]:
|
||||
return db.query(AudiobookChapter).filter(
|
||||
AudiobookChapter.project_id == project_id
|
||||
|
||||
@@ -43,6 +43,7 @@ def init_db():
|
||||
for col_def in [
|
||||
"ALTER TABLE audiobook_segments ADD COLUMN emo_text VARCHAR(20)",
|
||||
"ALTER TABLE audiobook_segments ADD COLUMN emo_alpha REAL",
|
||||
"ALTER TABLE audiobook_projects ADD COLUMN script_config JSON",
|
||||
]:
|
||||
try:
|
||||
conn.execute(__import__("sqlalchemy").text(col_def))
|
||||
|
||||
@@ -131,7 +131,8 @@ class AudiobookProject(Base):
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
user_id = Column(Integer, ForeignKey("users.id"), nullable=False, index=True)
|
||||
title = Column(String(500), nullable=False)
|
||||
source_type = Column(String(10), nullable=False)
|
||||
source_type = Column(String(20), nullable=False)
|
||||
script_config = Column(JSON, nullable=True)
|
||||
source_path = Column(String(500), nullable=True)
|
||||
source_text = Column(Text, nullable=True)
|
||||
status = Column(String(20), default="pending", nullable=False, index=True)
|
||||
|
||||
Reference in New Issue
Block a user