Skip to content

Commit

Permalink
日志,文档
Browse files Browse the repository at this point in the history
  • Loading branch information
FrostleafChan committed Dec 20, 2022
1 parent 82293a3 commit 2779d81
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion API.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ INFO: Application startup complete.



注意:若您需要合成对话语音,您还应按照 https://github.com/sudoskys/MoeGoe 中README和本项目README所述内容配置好语音合成服务器。
注意:若您需要合成对话语音,您还应按照 https://github.com/sudoskys/MoeGoe 中README和本项目README所述内容配置好语音合成服务器。语音合成目前仅支持中文。

## 接口签名

Expand Down
3 changes: 3 additions & 0 deletions API/Voice.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from utils.Data import TTS_REQ, TTS_Clint, Service_Data
from openai_async.utils.Talk import Talk
from fastapi.responses import Response
from loguru import logger

serviceCfg = Service_Data.get_key('./Config/service.json')
ttsConf = serviceCfg['tts']
Expand All @@ -11,6 +12,7 @@ class VITS:
def vits(text, task:int = 1, doReturnRawAudio: bool = True):
vitsConf = ttsConf['vits']
if(Talk.get_language(text) != 'chinese'):
logger.warning('语言不支持。语音合成目前仅支持合成中文')
return False
newtext = '[ZH]' + text + '[ZH]'
reqbody = TTS_REQ(model_name = vitsConf['model_name'],
Expand All @@ -19,6 +21,7 @@ def vits(text, task:int = 1, doReturnRawAudio: bool = True):
speaker_id = vitsConf['speaker_id'])
data = TTS_Clint.request_tts_server(url = vitsConf['api'], params = reqbody)
if(not data):
logger.warning('语言合成服务请求失败')
return False
if(doReturnRawAudio):
return Response(content = TTS_Clint.decode_wav(data['audio']), media_type = 'audio/x-pcm')
Expand Down

0 comments on commit 2779d81

Please sign in to comment.