Compare commits
2 Commits
d23ef5b2fa
...
d6d416cd1a
Author | SHA1 | Date | |
---|---|---|---|
d6d416cd1a | |||
71e18a595f |
5
DB.py
5
DB.py
@ -1,8 +1,11 @@
|
|||||||
|
import os
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
import peewee
|
import peewee
|
||||||
|
|
||||||
database = peewee.SqliteDatabase('voice_cache.sqlite')
|
DB_PATH = Path(os.getenv('DATA_DIR', '.')) / 'voice_cache.sqlite'
|
||||||
|
database = peewee.SqliteDatabase(str(DB_PATH))
|
||||||
|
|
||||||
|
|
||||||
class BaseModel(peewee.Model):
|
class BaseModel(peewee.Model):
|
||||||
|
33
Dockerfile
Normal file
33
Dockerfile
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
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"]
|
@ -1,7 +1,9 @@
|
|||||||
import contextlib
|
import contextlib
|
||||||
import os
|
|
||||||
import io
|
import io
|
||||||
|
import os
|
||||||
import wave
|
import wave
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
import torch.package
|
import torch.package
|
||||||
|
|
||||||
from .Speakers import Speakers
|
from .Speakers import Speakers
|
||||||
@ -12,12 +14,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 = 'model_multi.pt'
|
local_file = Path(os.getenv('DATA_DIR', '.')) / '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',
|
||||||
local_file
|
str(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")
|
||||||
|
BIN
logo_200x200.png
Normal file
BIN
logo_200x200.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.1 KiB |
4
main.py
4
main.py
@ -8,8 +8,10 @@ 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'
|
||||||
|
|
||||||
logger.add('offlineTTSBot.log', backtrace=True, diagnose=False, rotation='5MB')
|
if LOG_FILE_ENABLED:
|
||||||
|
logger.add('offlineTTSBot.log', backtrace=True, diagnose=False, rotation='5MB')
|
||||||
|
|
||||||
"""
|
"""
|
||||||
while msg := input('$ '):
|
while msg := input('$ '):
|
||||||
|
@ -2,7 +2,4 @@ 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
|
Loading…
x
Reference in New Issue
Block a user