Auto-update: Thu Aug 8 14:30:29 PDT 2024
This commit is contained in:
parent
6897e51fa0
commit
3d7ae743e6
3 changed files with 25 additions and 11 deletions
|
@ -29,6 +29,7 @@ News = Configuration.load('news', 'secrets')
|
||||||
Archivist = Configuration.load('archivist')
|
Archivist = Configuration.load('archivist')
|
||||||
Scrape = Configuration.load('scrape', 'secrets', Dir)
|
Scrape = Configuration.load('scrape', 'secrets', Dir)
|
||||||
Serve = Configuration.load('serve')
|
Serve = Configuration.load('serve')
|
||||||
|
Tts = Configuration.load('tts')
|
||||||
|
|
||||||
# Directories & general paths
|
# Directories & general paths
|
||||||
ROUTER_DIR = BASE_DIR / "routers"
|
ROUTER_DIR = BASE_DIR / "routers"
|
||||||
|
|
|
@ -1,10 +1,24 @@
|
||||||
default: xtts
|
default: xtts
|
||||||
email: xtts
|
email: xtts
|
||||||
webclip: 11L
|
webclip: elevenlabs
|
||||||
rss: xtts
|
rss: xtts
|
||||||
podcast_dir: '{{ DIR.HOME }}/Library/Mobile Documents/iCloud~co~supertop~castro/Documents/Sideloads'
|
|
||||||
xtts:
|
xtts:
|
||||||
voice: joanne
|
default: joanne
|
||||||
|
|
||||||
elevenlabs:
|
elevenlabs:
|
||||||
voice: luna
|
default: Victoria
|
||||||
api_key: '{{ SECRET.ELEVENLABS_API_KEY }}'
|
voices:
|
||||||
|
alloy: "E3A1KVbKoWSIKSZwSUsW"
|
||||||
|
echo: "b42GBisbu9r5m5n6pHF7"
|
||||||
|
fable: "KAX2Y6tTs0oDWq7zZXW7"
|
||||||
|
onyx: "clQb8NxY08xZ6mX6wCPE"
|
||||||
|
nova: "6TayTBKLMOsghG7jYuMX"
|
||||||
|
shimmer: "E7soeOyjpmuZFurvoxZ2"
|
||||||
|
Luna: "6TayTBKLMOsghG7jYuMX"
|
||||||
|
Sangye: "E7soeOyjpmuZFurvoxZ2"
|
||||||
|
Herzog: "KAX2Y6tTs0oDWq7zZXW7"
|
||||||
|
Attenborough: "b42GBisbu9r5m5n6pHF7"
|
||||||
|
Victoria: "7UBkHqZOtFRLq6cSMQQg"
|
||||||
|
|
||||||
|
api_key: "{{ SECRET.ELEVENLABS_API_KEY }}"
|
||||||
|
|
|
@ -27,7 +27,7 @@ import tempfile
|
||||||
import random
|
import random
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
from sijapi import L, Dir, DEFAULT_VOICE, TTS_SEGMENTS_DIR, VOICE_DIR, PODCAST_DIR, TTS_OUTPUT_DIR, ELEVENLABS_API_KEY
|
from sijapi import L, Dir, Tts, DEFAULT_VOICE, TTS_SEGMENTS_DIR, VOICE_DIR, PODCAST_DIR, TTS_OUTPUT_DIR, ELEVENLABS_API_KEY
|
||||||
from sijapi.utilities import sanitize_filename
|
from sijapi.utilities import sanitize_filename
|
||||||
|
|
||||||
### INITIALIZATIONS ###
|
### INITIALIZATIONS ###
|
||||||
|
@ -40,7 +40,6 @@ def err(text: str): logger.error(text)
|
||||||
def crit(text: str): logger.critical(text)
|
def crit(text: str): logger.critical(text)
|
||||||
|
|
||||||
DEVICE = torch.device('cpu')
|
DEVICE = torch.device('cpu')
|
||||||
MODEL_NAME = "tts_models/multilingual/multi-dataset/xtts_v2"
|
|
||||||
|
|
||||||
@tts.get("/tts/local_voices", response_model=List[str])
|
@tts.get("/tts/local_voices", response_model=List[str])
|
||||||
async def list_wav_files():
|
async def list_wav_files():
|
||||||
|
@ -211,7 +210,7 @@ async def determine_voice_id(voice_name: str) -> str:
|
||||||
"Victoria": "7UBkHqZOtFRLq6cSMQQg"
|
"Victoria": "7UBkHqZOtFRLq6cSMQQg"
|
||||||
}
|
}
|
||||||
|
|
||||||
if voice_name in hardcoded_voices:
|
if voice_name in Tts.elevenlabs.voices:
|
||||||
voice_id = hardcoded_voices[voice_name]
|
voice_id = hardcoded_voices[voice_name]
|
||||||
debug(f"Found voice ID - {voice_id}")
|
debug(f"Found voice ID - {voice_id}")
|
||||||
return voice_id
|
return voice_id
|
||||||
|
@ -232,7 +231,7 @@ async def determine_voice_id(voice_name: str) -> str:
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
err(f"Error determining voice ID: {str(e)}")
|
err(f"Error determining voice ID: {str(e)}")
|
||||||
|
|
||||||
# as a last fallback, rely on David Attenborough
|
# as a last fallback, rely on David Attenborough; move this to tts.yaml
|
||||||
return "b42GBisbu9r5m5n6pHF7"
|
return "b42GBisbu9r5m5n6pHF7"
|
||||||
|
|
||||||
|
|
||||||
|
@ -339,7 +338,7 @@ async def local_tts(
|
||||||
voice_file_path = await get_voice_file_path(voice, voice_file)
|
voice_file_path = await get_voice_file_path(voice, voice_file)
|
||||||
|
|
||||||
# Initialize TTS model in a separate thread
|
# Initialize TTS model in a separate thread
|
||||||
XTTS = await asyncio.to_thread(TTS, model_name=MODEL_NAME)
|
XTTS = await asyncio.to_thread(TTS, model_name=Tts.xtts.model)
|
||||||
await asyncio.to_thread(XTTS.to, DEVICE)
|
await asyncio.to_thread(XTTS.to, DEVICE)
|
||||||
|
|
||||||
segments = split_text(text_content)
|
segments = split_text(text_content)
|
||||||
|
@ -397,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:
|
||||||
output_dir = tempfile.mktemp(suffix=".wav", dir=tempfile.gettempdir())
|
output_dir = tempfile.mktemp(suffix=".wav", dir=tempfile.gettempdir())
|
||||||
|
|
||||||
XTTS = TTS(model_name=MODEL_NAME).to(DEVICE)
|
XTTS = TTS(model_name=Tts.xtts.model).to(DEVICE)
|
||||||
XTTS.tts_to_file(text=text, speed=speed, file_path=output_dir, speaker_wav=[voice_file_path], language="en")
|
XTTS.tts_to_file(text=text, speed=speed, file_path=output_dir, speaker_wav=[voice_file_path], language="en")
|
||||||
|
|
||||||
return output_dir
|
return output_dir
|
||||||
|
|
Loading…
Reference in a new issue