Compare commits

..

No commits in common. "d6d416cd1a72750896d5c3550fe218a1ef01b893" and "d23ef5b2fad66b6300b65c405e4baa8e5766fac8" have entirely different histories.

6 changed files with 9 additions and 46 deletions

5
DB.py
View File

@ -1,11 +1,8 @@
import os
from datetime import datetime from datetime import datetime
from pathlib import Path
import peewee import peewee
DB_PATH = Path(os.getenv('DATA_DIR', '.')) / 'voice_cache.sqlite' database = peewee.SqliteDatabase('voice_cache.sqlite')
database = peewee.SqliteDatabase(str(DB_PATH))
class BaseModel(peewee.Model): class BaseModel(peewee.Model):

View File

@ -1,33 +0,0 @@
FROM python:3.11-slim as builder
WORKDIR /app
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
RUN apt update && apt install git gcc -y --no-install-recommends && apt clean && rm -rf /var/lib/apt/lists/*
COPY requirements.txt .
RUN --mount=type=cache,target=/root/.cache/pip pip install Cython && \
pip wheel --no-deps --wheel-dir /app/wheels -r requirements.txt && \
pip wheel torch numpy --wheel-dir /app/wheels --index-url https://download.pytorch.org/whl/cpu
FROM python:3.11-slim
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
RUN useradd -ms /bin/bash silero_user
USER silero_user
WORKDIR /app
COPY --from=builder /app/wheels /wheels
COPY --from=builder /app/requirements.txt .
RUN pip install --no-cache /wheels/*
COPY . .
CMD ["python3", "/app/main.py"]

View File

@ -1,9 +1,7 @@
import contextlib import contextlib
import io
import os import os
import io
import wave import wave
from pathlib import Path
import torch.package import torch.package
from .Speakers import Speakers from .Speakers import Speakers
@ -14,12 +12,12 @@ class TTSSilero:
def __init__(self, threads: int = 12): def __init__(self, threads: int = 12):
device = torch.device('cpu') device = torch.device('cpu')
torch.set_num_threads(threads) torch.set_num_threads(threads)
local_file = Path(os.getenv('DATA_DIR', '.')) / 'model_multi.pt' local_file = 'model_multi.pt'
if not os.path.isfile(local_file): if not os.path.isfile(local_file):
torch.hub.download_url_to_file( torch.hub.download_url_to_file(
'https://models.silero.ai/models/tts/multi/v2_multi.pt', 'https://models.silero.ai/models/tts/multi/v2_multi.pt',
str(local_file) local_file
) )
self.model: TTSModelMulti_v2 = torch.package.PackageImporter(local_file).load_pickle("tts_models", "model") self.model: TTSModelMulti_v2 = torch.package.PackageImporter(local_file).load_pickle("tts_models", "model")

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

View File

@ -8,10 +8,8 @@ from loguru import logger
from DynamicCommandPrefix import dynamic_command_prefix from DynamicCommandPrefix import dynamic_command_prefix
import Observ import Observ
LOG_FILE_ENABLED = os.getenv('LOG_FILE_ENABLED', 'true').lower() == 'true'
if LOG_FILE_ENABLED: logger.add('offlineTTSBot.log', backtrace=True, diagnose=False, rotation='5MB')
logger.add('offlineTTSBot.log', backtrace=True, diagnose=False, rotation='5MB')
""" """
while msg := input('$ '): while msg := input('$ '):

View File

@ -2,4 +2,7 @@ discord-py
loguru~=0.6.0 loguru~=0.6.0
peewee~=3.14.10 peewee~=3.14.10
PyNaCl PyNaCl
Cython
torch
numpy
git+https://github.com/aaiyer/rfoo.git git+https://github.com/aaiyer/rfoo.git