bugfix
This commit is contained in:
parent
c008d8f0f0
commit
e30a53f13a
26
app/f5tts.py
26
app/f5tts.py
@ -58,18 +58,18 @@ sway_sampling_coef = -1.0
|
|||||||
speed = 1.0
|
speed = 1.0
|
||||||
|
|
||||||
def audio_ndarray_to_base64(waveform: np.ndarray, sample_rate: int = 16000) -> str:
|
def audio_ndarray_to_base64(waveform: np.ndarray, sample_rate: int = 16000) -> str:
|
||||||
# 如果是单通道,确保 shape 为 (samples, 1)
|
# 如果是单通道,确保 shape 为 (samples, 1)
|
||||||
if waveform.ndim == 1:
|
if waveform.ndim == 1:
|
||||||
waveform = waveform.reshape(-1, 1)
|
waveform = waveform.reshape(-1, 1)
|
||||||
|
|
||||||
# 写入内存 buffer(WAV 格式)
|
# 写入内存 buffer(WAV 格式)
|
||||||
buffer = io.BytesIO()
|
buffer = io.BytesIO()
|
||||||
sf.write(buffer, waveform, samplerate=sample_rate, format='WAV')
|
sf.write(buffer, waveform, samplerate=sample_rate, format='WAV')
|
||||||
buffer.seek(0)
|
buffer.seek(0)
|
||||||
|
|
||||||
# base64 编码
|
# base64 编码
|
||||||
b64_audio = base64.b64encode(buffer.read()).decode('utf-8')
|
b64_audio = base64.b64encode(buffer.read()).decode('utf-8')
|
||||||
return b64_audio
|
return b64_audio
|
||||||
|
|
||||||
def write_wav_buffer(wav, nchannels, framerate):
|
def write_wav_buffer(wav, nchannels, framerate):
|
||||||
fs = FileStorage()
|
fs = FileStorage()
|
||||||
@ -219,7 +219,8 @@ class F5TTS:
|
|||||||
|
|
||||||
def setup_voices(self):
|
def setup_voices(self):
|
||||||
config = getConfig()
|
config = getConfig()
|
||||||
workdir = get_serverenv('workdir')
|
workdir = config.workdir
|
||||||
|
print('workdir=', workdir)
|
||||||
d = None
|
d = None
|
||||||
with codecs.open(config.speakers_file, 'r', 'utf-8') as f:
|
with codecs.open(config.speakers_file, 'r', 'utf-8') as f:
|
||||||
b = f.read()
|
b = f.read()
|
||||||
@ -251,7 +252,7 @@ class F5TTS:
|
|||||||
async def add_voice(self, speaker, ref_audio, ref_text):
|
async def add_voice(self, speaker, ref_audio, ref_text):
|
||||||
config = getConfig()
|
config = getConfig()
|
||||||
ref_audio = FileStorage().realPath(ref_audio)
|
ref_audio = FileStorage().realPath(ref_audio)
|
||||||
workdir = get_serverenv('workdir')
|
workdir = config.workdir
|
||||||
filename = f'{getID()}.wav'
|
filename = f'{getID()}.wav'
|
||||||
fn = f'{workdir}/samples/{filename}'
|
fn = f'{workdir}/samples/{filename}'
|
||||||
await awaitify(self.copyfile)(ref_audio, fn)
|
await awaitify(self.copyfile)(ref_audio, fn)
|
||||||
@ -333,6 +334,7 @@ def init():
|
|||||||
global f5
|
global f5
|
||||||
g = ServerEnv()
|
g = ServerEnv()
|
||||||
f5 = F5TTS()
|
f5 = F5TTS()
|
||||||
|
g.tts_engine = f5
|
||||||
g.infer_stream = f5.infer_stream
|
g.infer_stream = f5.infer_stream
|
||||||
g.inference_stream = f5.inference_stream
|
g.inference_stream = f5.inference_stream
|
||||||
g.get_speakers = f5.get_speakers
|
g.get_speakers = f5.get_speakers
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
"ref_audio":"ttt.wav",
|
"ref_audio":"ttt.wav",
|
||||||
"ref_text":"快点吃饭,上课要迟到了。",
|
"ref_text":"快点吃饭,上课要迟到了。",
|
||||||
"cross_fade_duration":0,
|
"cross_fade_duration":0,
|
||||||
|
"workdir":"$[workdir]$",
|
||||||
"filesroot":"$[workdir]$/files",
|
"filesroot":"$[workdir]$/files",
|
||||||
"logger":{
|
"logger":{
|
||||||
"name":"f5tts",
|
"name":"f5tts",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"ymq": {
|
"ymq": {
|
||||||
"ref_text": "\u8f7b\u91cf\u5e94\u7528\u670d\u52a1\u5668\u5907\u6848\u6761\u4ef6\uff1a\u8d2d\u4e70\u65f6\u957f\u57283\u4e2a\u6708\u53ca\u4ee5\u4e0a",
|
"ref_text": "\u8f7b\u91cf\u5e94\u7528\u670d\u52a1\u5668\u5907\u6848\u6761\u4ef6\uff1a\u8d2d\u4e70\u65f6\u957f\u57283\u4e2a\u6708\u53ca\u4ee5\u4e0a",
|
||||||
"ref_audio": "samples/ymq.wav"
|
"ref_audio": "ymq.wav"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,8 @@ User=ymq
|
|||||||
Group=ymq
|
Group=ymq
|
||||||
WorkingDirectory=/share/ymq/run/f5tts
|
WorkingDirectory=/share/ymq/run/f5tts
|
||||||
Type=forking
|
Type=forking
|
||||||
ExecStart=/share/ymq/run/f5tts/run.sh
|
ExecStart=/share/ymq/run/f5tts/start.sh
|
||||||
|
ExecStop=/share/ymq/run/f5tts/stop.sh
|
||||||
StandardOutput=append:/var/log/f5tts/f5tts.log
|
StandardOutput=append:/var/log/f5tts/f5tts.log
|
||||||
StandardError=append:/var/log/f5tts/f5tts.log
|
StandardError=append:/var/log/f5tts/f5tts.log
|
||||||
SyslogIdentifier=f5tts
|
SyslogIdentifier=f5tts
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
numpy
|
numpy
|
||||||
soundfile
|
soundfile
|
||||||
cached_path
|
cached_path
|
||||||
|
redis
|
||||||
pycld2
|
pycld2
|
||||||
cn2an
|
cn2an
|
||||||
apppublic
|
git+https://git.kaiyuancloud.cn/yumoqing/apppublic
|
||||||
sqlor
|
git+https://git.kaiyuancloud.cn/yumoqing/sqlor
|
||||||
ahserver
|
git+https://git.kaiyuancloud.cn/yumoqing/ahserver
|
||||||
file2text
|
git+https://git.kaiyuancloud.cn/yumoqing/filetxt
|
||||||
# git+https://github.com/SWivid/F5-TTS
|
# git+https://github.com/SWivid/F5-TTS
|
||||||
|
5
run.sh
5
run.sh
@ -1,5 +0,0 @@
|
|||||||
echo start 3 instances for f5tts engine
|
|
||||||
rundir=/share/ymq/run/f5tts
|
|
||||||
CUDA_VISIBLE_DEVICES=4 ${rundir}/f5tts.env/bin/python ${rundir}/app/f5tts.py -w ${rundir} -p 9995 &
|
|
||||||
CUDA_VISIBLE_DEVICES=4 ${rundir}/f5tts.env/bin/python ${rundir}/app/f5tts.py -w ${rundir} -p 9995 &
|
|
||||||
|
|
10
start.sh
Executable file
10
start.sh
Executable file
@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/bash
|
||||||
|
|
||||||
|
echo start 3 instances for f5tts engine
|
||||||
|
rundir=/share/ymq/run/f5tts
|
||||||
|
CUDA_VISIBLE_DEVICES=6 ${rundir}/f5tts.env/bin/python ${rundir}/app/f5tts.py -w ${rundir} -p 9995 &
|
||||||
|
CUDA_VISIBLE_DEVICES=6 ${rundir}/f5tts.env/bin/python ${rundir}/app/f5tts.py -w ${rundir} -p 9995 &
|
||||||
|
CUDA_VISIBLE_DEVICES=6 ${rundir}/f5tts.env/bin/python ${rundir}/app/f5tts.py -w ${rundir} -p 9995 &
|
||||||
|
CUDA_VISIBLE_DEVICES=6 ${rundir}/f5tts.env/bin/python ${rundir}/app/f5tts.py -w ${rundir} -p 9995 &
|
||||||
|
|
||||||
|
exit 0
|
Loading…
Reference in New Issue
Block a user