Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker fix && Voice Fix #385

Merged
merged 3 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ RUN apt update && \
apt install -y ffmpeg && \
pip install pdm

VOLUME ["/redis", "/rabbitmq", "/mongodb", "/run.log", "/config_dir"]
VOLUME ["/redis", "/rabbitmq", "/mongodb", "/run.log", ".cache",".montydb",".snapshot"]

WORKDIR /app
COPY --from=builder /project/.venv /app/.venv

COPY pm2.json ./
COPY config_dir ./config_dir
COPY . /app

CMD [ "pm2-runtime", "pm2.json" ]
9 changes: 6 additions & 3 deletions llmkira/extra/voice/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import base64
import json
from io import BytesIO
from typing import Optional

import aiohttp
import edge_tts
Expand Down Expand Up @@ -49,7 +50,8 @@ def get_audio_bytes_from_data_url(data_url):
audio_base64 = data_url.split(",")[1]
audio_bytes = base64.b64decode(audio_base64)
return audio_bytes
except Exception:
except Exception as e:
logger.warning(f"Failed to extract audio bytes: {e}")
return None


Expand Down Expand Up @@ -143,7 +145,7 @@ async def request_novelai_speech(text):
return None


async def request_cn(text, reecho_api_key: str = None):
async def request_cn(text, reecho_api_key: str = None) -> Optional[bytes]:
"""
Call the Reecho endpoint to generate synthesized voice.
:param text: The text to synthesize
Expand All @@ -156,9 +158,10 @@ async def request_cn(text, reecho_api_key: str = None):
stt = await request_reecho_speech(text, reecho_api_key)
if not stt:
return await request_dui_speech(text)
return stt


async def request_en(text):
async def request_en(text) -> Optional[bytes]:
"""
Call the Reecho endpoint to generate synthesized voice.
:param text: The text to synthesize
Expand Down
Loading