diff --git a/modeldownload.json b/modeldownload.json index 76afdcd..d18ab27 100644 --- a/modeldownload.json +++ b/modeldownload.json @@ -8,6 +8,7 @@ "model.pth": "https://huggingface.co/coqui/XTTS-v2/resolve/v2.0.2/model.pth?download=true", "dvae.pth": "https://huggingface.co/coqui/XTTS-v2/resolve/v2.0.2/dvae.pth?download=true", "mel_stats.pth": "https://huggingface.co/coqui/XTTS-v2/resolve/v2.0.2/mel_stats.pth?download=true", + "speakers_xtts.pth": "https://huggingface.co/coqui/XTTS-v2/resolve/v2.0.2/speakers_xtts.pth?download=true", "vocab.json": "https://huggingface.co/coqui/XTTS-v2/resolve/v2.0.2/vocab.json?download=true" } -} +} \ No newline at end of file diff --git a/requirements_nvidia.txt b/requirements_nvidia.txt index 82579fd..ef574c4 100644 --- a/requirements_nvidia.txt +++ b/requirements_nvidia.txt @@ -11,3 +11,4 @@ tqdm>=4.66.1 importlib-metadata>=4.8.1 packaging>=23.2 pydantic>=1.10.13 +sounddevice>=0.4.6 diff --git a/requirements_other.txt b/requirements_other.txt index aad8a62..8bc9597 100644 --- a/requirements_other.txt +++ b/requirements_other.txt @@ -11,3 +11,4 @@ tqdm>=4.66.1 importlib-metadata>=4.8.1 packaging>=23.2 pydantic>=1.10.13 +sounddevice>=0.4.6 diff --git a/tts_server.py b/tts_server.py index c92b87d..95cd725 100644 --- a/tts_server.py +++ b/tts_server.py @@ -674,9 +674,15 @@ import re import uuid import numpy as np import soundfile as sf +import sounddevice as sd from typing import Union, Dict from pydantic import BaseModel, ValidationError, Field +def play_audio(file_path, volume): + data, fs = sf.read(file_path) + sd.play(volume * data, fs) + sd.wait() + class Request(BaseModel): # Define the structure of the 'Request' class if needed pass @@ -874,6 +880,8 @@ async def tts_generate( else: cleaned_string = text_input await generate_audio(cleaned_string, character_voice_gen, language, output_file_path) + if autoplay: + play_audio(output_file_path, autoplay_volume) return JSONResponse(content={"status": "generate-success", "output_file_path": str(output_file_path), "output_file_url": str(output_file_url)}, status_code=200) except Exception as e: return JSONResponse(content={"status": "generate-failure", "error": "An error occurred"}, status_code=500)