mirror of
https://github.com/BoardWare-Genius/jarvis-models.git
synced 2025-12-13 16:53:24 +00:00
Blackbox melotts updated
This commit is contained in:
@ -26,12 +26,15 @@ class MeloTTS(Blackbox):
|
|||||||
text = args[0]
|
text = args[0]
|
||||||
return isinstance(text, str)
|
return isinstance(text, str)
|
||||||
|
|
||||||
def processing(self, *args, **kwargs) -> io.BytesIO:
|
def processing(self, *args, **kwargs) -> bytes:
|
||||||
text = args[0]
|
text = args[0]
|
||||||
current_time = time.time()
|
current_time = time.time()
|
||||||
audio = self.tts_service.read(text)
|
message = {
|
||||||
|
"text": text
|
||||||
|
}
|
||||||
|
response = requests.post(self.melotts, json=message)
|
||||||
print("#### MeloTTS Service consume : ", (time.time()-current_time))
|
print("#### MeloTTS Service consume : ", (time.time()-current_time))
|
||||||
return audio
|
return response.content
|
||||||
|
|
||||||
async def fast_api_handler(self, request: Request) -> Response:
|
async def fast_api_handler(self, request: Request) -> Response:
|
||||||
try:
|
try:
|
||||||
@ -41,7 +44,6 @@ class MeloTTS(Blackbox):
|
|||||||
text = data.get("text")
|
text = data.get("text")
|
||||||
if text is None:
|
if text is None:
|
||||||
return JSONResponse(content={"error": "text is required"}, status_code=status.HTTP_400_BAD_REQUEST)
|
return JSONResponse(content={"error": "text is required"}, status_code=status.HTTP_400_BAD_REQUEST)
|
||||||
by = self.processing(text)
|
return Response(content=self.processing(text), media_type="audio/wav", headers={"Content-Disposition": "attachment; filename=audio.wav"})
|
||||||
return Response(content=by.read(), media_type="audio/mp3", headers={"Content-Disposition": "attachment; filename=audio.mp3"})
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user