Skip to content

Commit

Permalink
Merge pull request #385 from LlmKira/dev
Browse files Browse the repository at this point in the history
Docker fix && Voice Fix
  • Loading branch information
sudoskys authored Apr 18, 2024
2 parents 1a58d1f + 80a4e0b commit c1fa18e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
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

0 comments on commit c1fa18e

Please sign in to comment.