Auto-update: Thu Aug 8 06:18:49 PDT 2024
This commit is contained in:
parent
ecd06715dd
commit
1f4c7622d3
3 changed files with 8 additions and 10 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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)}")
|
||||
|
||||
|
|
Loading…
Reference in a new issue