From 1f4c7622d331a5db6f8f9f1aaf907a2a6bfc6e28 Mon Sep 17 00:00:00 2001 From: sanj <67624670+iodrift@users.noreply.github.com> Date: Thu, 8 Aug 2024 06:18:49 -0700 Subject: [PATCH] Auto-update: Thu Aug 8 06:18:49 PDT 2024 --- sijapi/routers/img.py | 4 ---- sijapi/routers/news.py | 8 +++----- sijapi/routers/tts.py | 6 +++++- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/sijapi/routers/img.py b/sijapi/routers/img.py index 80e374b..a5f6262 100644 --- a/sijapi/routers/img.py +++ b/sijapi/routers/img.py @@ -1,9 +1,5 @@ ''' Image generation module using StableDiffusion and similar models by way of ComfyUI. -DEPENDS ON: - LLM module - COMFYUI_URL, COMFYUI_DIR, COMFYUI_OUTPUT_DIR, TS_SUBNET, TS_ADDRESS, DATA_DIR, IMG_CONFIG_DIR, IMG_DIR, IMG_WORKFLOWS_DIR, LOCAL_HOSTS -*unimplemented. ''' #routers/img.py diff --git a/sijapi/routers/news.py b/sijapi/routers/news.py index 8f9d664..b8276a7 100644 --- a/sijapi/routers/news.py +++ b/sijapi/routers/news.py @@ -65,7 +65,7 @@ async def generate_summary(text: str) -> str: summary = await llm.summarize_text(text, "Summarize the provided text. Respond with the summary and nothing else.") return summary.replace('\n', ' ') -async def handle_tts(bg_tasks: BackgroundTasks, article: Article, title: str, tts_mode: str, voice: str, summary: str) -> Optional[str]: +async def handle_tts(bg_tasks: BackgroundTasks, article: Article, title: str, tts_mode: str, voice: str, summary: str, model: str = "eleven_turbo_v2") -> Optional[str]: if tts_mode in ["full", "content"]: tts_text = article.text elif tts_mode in ["summary", "excerpt"]: @@ -79,12 +79,13 @@ async def handle_tts(bg_tasks: BackgroundTasks, article: Article, title: str, tt bg_tasks=bg_tasks, text=tts_text, voice=voice, - model="xtts", + model=model, podcast=True, title=audio_filename, output_dir=Path(OBSIDIAN_VAULT_DIR) / OBSIDIAN_RESOURCES_DIR ) return f"![[{Path(audio_path).name}]]" + except HTTPException as e: err(f"Failed to generate TTS: {str(e)}") return None @@ -182,9 +183,6 @@ async def process_and_save_article( # Save markdown file await save_markdown_file(markdown_filename, markdown_content) - # Add to daily note - # await note.add_to_daily_note(relative_path) - return f"Successfully saved: {relative_path}" except Exception as e: diff --git a/sijapi/routers/tts.py b/sijapi/routers/tts.py index 7b59c0a..f3fb30a 100644 --- a/sijapi/routers/tts.py +++ b/sijapi/routers/tts.py @@ -147,6 +147,7 @@ async def generate_speech( if model == "eleven_turbo_v2": info("Using ElevenLabs.") + voice = determine_voice_id(voice) audio_file_path = await elevenlabs_tts(model, text, voice, title, output_dir) else: # if model == "xtts": info("Using XTTS2") @@ -182,6 +183,7 @@ async def get_model(voice: str = None, voice_file: UploadFile = None): async def determine_voice_id(voice_name: str) -> str: debug(f"Searching for voice id for {voice_name}") + # Todo: move this to tts.yaml hardcoded_voices = { "alloy": "E3A1KVbKoWSIKSZwSUsW", "echo": "b42GBisbu9r5m5n6pHF7", @@ -192,7 +194,8 @@ async def determine_voice_id(voice_name: str) -> str: "Luna": "6TayTBKLMOsghG7jYuMX", "Sangye": "E7soeOyjpmuZFurvoxZ2", "Herzog": "KAX2Y6tTs0oDWq7zZXW7", - "Attenborough": "b42GBisbu9r5m5n6pHF7" + "Attenborough": "b42GBisbu9r5m5n6pHF7", + "Victoria": "7UBkHqZOtFRLq6cSMQQg" } if voice_name in hardcoded_voices: @@ -212,6 +215,7 @@ async def determine_voice_id(voice_name: str) -> str: for voice in voices_data: if voice_name == voice["voice_id"] or voice_name == voice["name"]: return voice["voice_id"] + except Exception as e: err(f"Error determining voice ID: {str(e)}")