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

+8
View File
@@ -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)