Auto-update: Thu Aug 8 16:39:27 PDT 2024
This commit is contained in:
parent
ba87576f83
commit
ffe1e47cdf
2 changed files with 13 additions and 13 deletions
|
@ -125,11 +125,11 @@ async def hook_alert(request: Request):
|
||||||
async def notify(alert: str):
|
async def notify(alert: str):
|
||||||
fail = True
|
fail = True
|
||||||
try:
|
try:
|
||||||
if API.EXTENSIONS.shellfish == True:
|
if API.EXTENSIONS.shellfish:
|
||||||
await notify_shellfish(alert)
|
await notify_shellfish(alert)
|
||||||
fail = False
|
fail = False
|
||||||
|
|
||||||
if API.EXTENSIONS.macnotify == True:
|
if API.EXTENSIONS.macnotify:
|
||||||
if TS_ID == MAC_ID:
|
if TS_ID == MAC_ID:
|
||||||
await notify_local(alert)
|
await notify_local(alert)
|
||||||
fail = False
|
fail = False
|
||||||
|
@ -165,7 +165,7 @@ async def notify_remote(host: str, message: str, username: str = None, password:
|
||||||
ssh.close()
|
ssh.close()
|
||||||
|
|
||||||
|
|
||||||
if API.EXTENSIONS.shellfish == True:
|
if API.EXTENSIONS.shellfish:
|
||||||
async def notify_shellfish(alert: str):
|
async def notify_shellfish(alert: str):
|
||||||
key = "d7e810e7601cd296a05776c169b4fe97a6a5ee1fd46abe38de54f415732b3f4b"
|
key = "d7e810e7601cd296a05776c169b4fe97a6a5ee1fd46abe38de54f415732b3f4b"
|
||||||
user = "WuqPwm1VpGijF4U5AnIKzqNMVWGioANTRjJoonPm"
|
user = "WuqPwm1VpGijF4U5AnIKzqNMVWGioANTRjJoonPm"
|
||||||
|
@ -250,7 +250,7 @@ if API.EXTENSIONS.shellfish == True:
|
||||||
return result.stdout
|
return result.stdout
|
||||||
|
|
||||||
|
|
||||||
if API.EXTENSIONS.courtlistener == True:
|
if API.EXTENSIONS.courtlistener:
|
||||||
with open(CASETABLE_PATH, 'r') as file:
|
with open(CASETABLE_PATH, 'r') as file:
|
||||||
CASETABLE = json.load(file)
|
CASETABLE = json.load(file)
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ import tempfile
|
||||||
import random
|
import random
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
from sijapi import L, API, Dir, Tts, TTS_SEGMENTS_DIR, VOICE_DIR, TTS_OUTPUT_DIR, ELEVENLABS_API_KEY
|
from sijapi import L, API, Dir, Tts, TTS_SEGMENTS_DIR, VOICE_DIR, TTS_OUTPUT_DIR
|
||||||
from sijapi.utilities import sanitize_filename
|
from sijapi.utilities import sanitize_filename
|
||||||
|
|
||||||
### INITIALIZATIONS ###
|
### INITIALIZATIONS ###
|
||||||
|
@ -49,7 +49,7 @@ async def list_wav_files():
|
||||||
async def list_11l_voices():
|
async def list_11l_voices():
|
||||||
formatted_list = ""
|
formatted_list = ""
|
||||||
url = "https://api.elevenlabs.io/v1/voices"
|
url = "https://api.elevenlabs.io/v1/voices"
|
||||||
headers = {"xi-api-key": ELEVENLABS_API_KEY}
|
headers = {"xi-api-key": Tts.elevenlabs.api_key}
|
||||||
async with httpx.AsyncClient() as client:
|
async with httpx.AsyncClient() as client:
|
||||||
try:
|
try:
|
||||||
response = await client.get(url, headers=headers)
|
response = await client.get(url, headers=headers)
|
||||||
|
@ -146,7 +146,7 @@ async def generate_speech(
|
||||||
if model == "eleven_turbo_v2" and API.EXTENSIONS.elevenlabs == True:
|
if model == "eleven_turbo_v2" and API.EXTENSIONS.elevenlabs == True:
|
||||||
info("Using ElevenLabs.")
|
info("Using ElevenLabs.")
|
||||||
audio_file_path = await elevenlabs_tts(model, text, voice, title, output_dir)
|
audio_file_path = await elevenlabs_tts(model, text, voice, title, output_dir)
|
||||||
elif API.EXTENSIONS.xtts == True:
|
elif API.EXTENSIONS.xtts:
|
||||||
info("Using XTTS2")
|
info("Using XTTS2")
|
||||||
audio_file_path = await local_tts(text, speed, voice, voice_file, podcast, bg_tasks, title, output_path)
|
audio_file_path = await local_tts(text, speed, voice, voice_file, podcast, bg_tasks, title, output_path)
|
||||||
else:
|
else:
|
||||||
|
@ -205,7 +205,7 @@ async def determine_voice_id(voice_name: str) -> str:
|
||||||
|
|
||||||
debug(f"Requested voice not among the voices specified in config/tts.yaml. Checking with 11L next.")
|
debug(f"Requested voice not among the voices specified in config/tts.yaml. Checking with 11L next.")
|
||||||
url = "https://api.elevenlabs.io/v1/voices"
|
url = "https://api.elevenlabs.io/v1/voices"
|
||||||
headers = {"xi-api-key": ELEVENLABS_API_KEY}
|
headers = {"xi-api-key": Tts.elevenlabs.api_key}
|
||||||
async with httpx.AsyncClient() as client:
|
async with httpx.AsyncClient() as client:
|
||||||
try:
|
try:
|
||||||
response = await client.get(url, headers=headers)
|
response = await client.get(url, headers=headers)
|
||||||
|
@ -225,7 +225,7 @@ async def determine_voice_id(voice_name: str) -> str:
|
||||||
|
|
||||||
async def elevenlabs_tts(model: str, input_text: str, voice: str, title: str = None, output_dir: str = None):
|
async def elevenlabs_tts(model: str, input_text: str, voice: str, title: str = None, output_dir: str = None):
|
||||||
|
|
||||||
if API.EXTENSIONS.elevenlabs == True:
|
if API.EXTENSIONS.elevenlabs:
|
||||||
voice_id = await determine_voice_id(voice)
|
voice_id = await determine_voice_id(voice)
|
||||||
|
|
||||||
url = f"https://api.elevenlabs.io/v1/text-to-speech/{voice_id}"
|
url = f"https://api.elevenlabs.io/v1/text-to-speech/{voice_id}"
|
||||||
|
@ -233,7 +233,7 @@ async def elevenlabs_tts(model: str, input_text: str, voice: str, title: str = N
|
||||||
"text": input_text,
|
"text": input_text,
|
||||||
"model_id": model
|
"model_id": model
|
||||||
}
|
}
|
||||||
headers = {"Content-Type": "application/json", "xi-api-key": ELEVENLABS_API_KEY}
|
headers = {"Content-Type": "application/json", "xi-api-key": Tts.elevenlabs.api_key}
|
||||||
try:
|
try:
|
||||||
async with httpx.AsyncClient(timeout=httpx.Timeout(300.0)) as client: # 5 minutes timeout
|
async with httpx.AsyncClient(timeout=httpx.Timeout(300.0)) as client: # 5 minutes timeout
|
||||||
response = await client.post(url, json=payload, headers=headers)
|
response = await client.post(url, json=payload, headers=headers)
|
||||||
|
@ -318,7 +318,7 @@ async def local_tts(
|
||||||
output_path: Optional[Path] = None
|
output_path: Optional[Path] = None
|
||||||
) -> str:
|
) -> str:
|
||||||
|
|
||||||
if API.EXTENSIONS.xtts == True:
|
if API.EXTENSIONS.xtts:
|
||||||
from TTS.api import TTS
|
from TTS.api import TTS
|
||||||
|
|
||||||
if output_path:
|
if output_path:
|
||||||
|
@ -396,7 +396,7 @@ async def stream_tts(text_content: str, speed: float, voice: str, voice_file) ->
|
||||||
|
|
||||||
async def generate_tts(text: str, speed: float, voice_file_path: str) -> str:
|
async def generate_tts(text: str, speed: float, voice_file_path: str) -> str:
|
||||||
|
|
||||||
if API.EXTENSIONS.xtts == True:
|
if API.EXTENSIONS.xtts:
|
||||||
from TTS.api import TTS
|
from TTS.api import TTS
|
||||||
|
|
||||||
output_dir = tempfile.mktemp(suffix=".wav", dir=tempfile.gettempdir())
|
output_dir = tempfile.mktemp(suffix=".wav", dir=tempfile.gettempdir())
|
||||||
|
@ -418,7 +418,7 @@ async def get_audio_stream(model: str, input_text: str, voice: str):
|
||||||
"text": input_text,
|
"text": input_text,
|
||||||
"model_id": "eleven_turbo_v2"
|
"model_id": "eleven_turbo_v2"
|
||||||
}
|
}
|
||||||
headers = {"Content-Type": "application/json", "xi-api-key": ELEVENLABS_API_KEY}
|
headers = {"Content-Type": "application/json", "xi-api-key": Tts.elevenlabs.api_key}
|
||||||
response = requests.post(url, json=payload, headers=headers)
|
response = requests.post(url, json=payload, headers=headers)
|
||||||
|
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
|
|
Loading…
Reference in a new issue