updated skeleton with true data
This commit is contained in:
@ -1 +1,7 @@
|
||||
FROM nvidia/cuda:12.1.0-runtime-ubuntu22.04
|
||||
FROM nvidia/cuda:12.1.0-runtime-ubuntu22.04 AS base
|
||||
WORKDIR /app
|
||||
COPY requirements.worker.txt .
|
||||
RUN apt-get update && apt-get install -y python3-pip ffmpeg
|
||||
RUN pip3 install -r requirements.worker.txt
|
||||
COPY . .
|
||||
CMD ["python3","main.py"]
|
||||
|
||||
4
worker/core/gpu_detect.py
Normal file
4
worker/core/gpu_detect.py
Normal file
@ -0,0 +1,4 @@
|
||||
import torch
|
||||
|
||||
def device():
|
||||
return 'cuda' if torch.cuda.is_available() else 'cpu'
|
||||
18
worker/core/queue_worker.py
Normal file
18
worker/core/queue_worker.py
Normal file
@ -0,0 +1,18 @@
|
||||
import redis, json, os
|
||||
|
||||
REDIS_HOST=os.environ.get("REDIS_HOST","redis")
|
||||
r=redis.Redis(host=REDIS_HOST, port=6379, db=0)
|
||||
|
||||
QUEUE="tts_queue"
|
||||
RESULT="tts_result"
|
||||
|
||||
def fetch_job():
|
||||
data=r.rpop(QUEUE)
|
||||
if not data:
|
||||
return None
|
||||
return json.loads(data)
|
||||
|
||||
def store_result(job_id:str, audio:bytes, mime:str):
|
||||
key=f"{RESULT}:{job_id}"
|
||||
obj={"audio": audio.hex(), "mime": mime}
|
||||
r.set(key, json.dumps(obj))
|
||||
19
worker/engine/audio_export.py
Normal file
19
worker/engine/audio_export.py
Normal file
@ -0,0 +1,19 @@
|
||||
from pydub import AudioSegment
|
||||
import io
|
||||
|
||||
def convert_audio(raw_bytes: bytes, fmt: str):
|
||||
# raw mono 32-bit float fake waveform
|
||||
seg = AudioSegment(
|
||||
raw_bytes,
|
||||
frame_rate=22050,
|
||||
sample_width=4,
|
||||
channels=1
|
||||
)
|
||||
buf=io.BytesIO()
|
||||
seg.export(buf, format=fmt)
|
||||
mime={
|
||||
"wav":"audio/wav",
|
||||
"mp3":"audio/mpeg",
|
||||
"ogg":"audio/ogg"
|
||||
}.get(fmt,"audio/wav")
|
||||
return buf.getvalue(), mime
|
||||
10
worker/engine/xtts2_loader.py
Normal file
10
worker/engine/xtts2_loader.py
Normal file
@ -0,0 +1,10 @@
|
||||
# Dummy XTTS2 logic placeholder
|
||||
# Replace with real TTS model loading
|
||||
|
||||
def synthesize(job: dict):
|
||||
# return artificial sine wave placeholder
|
||||
import numpy as np
|
||||
sr=22050
|
||||
t=np.linspace(0,0.3,int(sr*0.3))
|
||||
tone=(0.1*np.sin(2*np.pi*440*t)).astype('float32')
|
||||
return tone.tobytes()
|
||||
@ -1 +1,16 @@
|
||||
print('worker start')
|
||||
import time, json, os
|
||||
from core.queue_worker import fetch_job, store_result
|
||||
from engine.xtts2_loader import synthesize
|
||||
from engine.audio_export import convert_audio
|
||||
|
||||
print("Worker gestartet. Warte auf Jobs…")
|
||||
|
||||
while True:
|
||||
job = fetch_job()
|
||||
if not job:
|
||||
time.sleep(0.1)
|
||||
continue
|
||||
|
||||
audio = synthesize(job)
|
||||
out, mime = convert_audio(audio, job.get("format","wav"))
|
||||
store_result(job["job_id"], out, mime)
|
||||
|
||||
@ -1 +1,5 @@
|
||||
TTS
|
||||
pydub
|
||||
redis
|
||||
torch
|
||||
numpy
|
||||
requests
|
||||
|
||||
1
worker/voices/registry.json
Normal file
1
worker/voices/registry.json
Normal file
@ -0,0 +1 @@
|
||||
{}
|
||||
Reference in New Issue
Block a user