Supports playback at the command line prompt

Added sounddevice as its currently well supported. Allows playback at the terminal/command prompt. 
Added speakers_xtts.pth to the modeldownload.json as it will be needed for finetuning in future updates of TTS 0.22.0+
This commit is contained in:
erew123 authored and GitHub committed 2023-12-29 10:42:35 +00:00
1 parent e81a88938a
commit 221efbddb4
4 files changed
+12 -1

No files matched your search

+2 -1
View File
@@ -8,6 +8,7 @@
"model.pth": "https://huggingface.co/coqui/XTTS-v2/resolve/v2.0.2/model.pth?download=true", "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", "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", "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" "vocab.json": "https://huggingface.co/coqui/XTTS-v2/resolve/v2.0.2/vocab.json?download=true"
} }
} }
+1
View File
@@ -11,3 +11,4 @@ tqdm>=4.66.1
importlib-metadata>=4.8.1 importlib-metadata>=4.8.1
packaging>=23.2 packaging>=23.2
pydantic>=1.10.13 pydantic>=1.10.13
sounddevice>=0.4.6
+1
View File
@@ -11,3 +11,4 @@ tqdm>=4.66.1
importlib-metadata>=4.8.1 importlib-metadata>=4.8.1
packaging>=23.2 packaging>=23.2
pydantic>=1.10.13 pydantic>=1.10.13
sounddevice>=0.4.6
+8
View File
@@ -674,9 +674,15 @@ import re
import uuid import uuid
import numpy as np import numpy as np
import soundfile as sf import soundfile as sf
import sounddevice as sd
from typing import Union, Dict from typing import Union, Dict
from pydantic import BaseModel, ValidationError, Field 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): class Request(BaseModel):
# Define the structure of the 'Request' class if needed # Define the structure of the 'Request' class if needed
pass pass
@@ -874,6 +880,8 @@ async def tts_generate(
else: else:
cleaned_string = text_input cleaned_string = text_input
await generate_audio(cleaned_string, character_voice_gen, language, output_file_path) 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) 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: except Exception as e:
return JSONResponse(content={"status": "generate-failure", "error": "An error occurred"}, status_code=500) return JSONResponse(content={"status": "generate-failure", "error": "An error occurred"}, status_code=500)