From c008d8f0f093529612cf26e72aae23bb387f89e7 Mon Sep 17 00:00:00 2001 From: ymq1 Date: Fri, 13 Jun 2025 13:48:09 +0000 Subject: [PATCH] bugfix --- app/f5tts.py | 17 +++++++++++------ conf/config.json | 2 +- conf/speakers.json | 2 +- f5tts.service | 15 +++++++++++++++ logs/stderr.log | 15 --------------- run.sh | 5 +++++ samples/{test.wav => ymq.wav} | Bin 7 files changed, 33 insertions(+), 23 deletions(-) create mode 100644 f5tts.service create mode 100755 run.sh rename samples/{test.wav => ymq.wav} (100%) diff --git a/app/f5tts.py b/app/f5tts.py index eb328cf..3ce9c8c 100644 --- a/app/f5tts.py +++ b/app/f5tts.py @@ -219,11 +219,14 @@ class F5TTS: def setup_voices(self): config = getConfig() + workdir = get_serverenv('workdir') d = None with codecs.open(config.speakers_file, 'r', 'utf-8') as f: b = f.read() self.speakers = json.loads(b) - ref_audio, ref_text = preprocess_ref_audio_text(config.ref_audio, config.ref_text) + fn = f'{workdir}/samples/{config.ref_audio}' + ref_audio, ref_text = preprocess_ref_audio_text(fn, + config.ref_text) self.voices = { "main":{ 'ref_text':ref_text, @@ -231,7 +234,9 @@ class F5TTS: } } for k,v in self.speakers.items(): - ref_audio, ref_text = preprocess_ref_audio_text(v['ref_audio'], v['ref_text']) + fn = f'{workdir}/samples/{v["ref_audio"]}' + ref_audio, ref_text = preprocess_ref_audio_text(fn, + v['ref_text']) self.voices[k] = { 'ref_text':ref_text, 'ref_audio':ref_audio @@ -244,22 +249,22 @@ class F5TTS: f1.write(b) async def add_voice(self, speaker, ref_audio, ref_text): - debug(f'{speaker=}, {ref_audio=}, {ref_text=}'); config = getConfig() ref_audio = FileStorage().realPath(ref_audio) workdir = get_serverenv('workdir') - fn = f'{workdir}/samples/{getID()}.wav' + filename = f'{getID()}.wav' + fn = f'{workdir}/samples/{filename}' await awaitify(self.copyfile)(ref_audio, fn) os.unlink(ref_adio) self.speakers[speaker] = { 'ref_text':ref_text, - 'ref_audio':fn + 'ref_audio':filename } f = awaitify(preprocess_ref_audio_text) ref_audio, ref_text = await f(ref_audio, ref_text) self.voices[speaker] = { 'ref_text':ref_text, - 'ref_audio':fn + 'ref_audio':filename } with codecs.open(config.speakers_file, 'w', 'utf-8') as f: f.write(json.dumps(self.speakers, indent=4, ensure_ascii=False)) diff --git a/conf/config.json b/conf/config.json index 7ef3501..f74440e 100644 --- a/conf/config.json +++ b/conf/config.json @@ -18,7 +18,7 @@ "remove_silence":false, "modelname":"F5-TTS", "device":"cuda:0", - "ref_audio":"$[workdir]$/samples/ttt.wav", + "ref_audio":"ttt.wav", "ref_text":"快点吃饭,上课要迟到了。", "cross_fade_duration":0, "filesroot":"$[workdir]$/files", diff --git a/conf/speakers.json b/conf/speakers.json index 9b0ea52..053725c 100644 --- a/conf/speakers.json +++ b/conf/speakers.json @@ -1,6 +1,6 @@ { "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_audio": "/data/ymq/py/f5tts/files/87/103/66/49/record.wav" + "ref_audio": "samples/ymq.wav" } } diff --git a/f5tts.service b/f5tts.service new file mode 100644 index 0000000..ba7ad69 --- /dev/null +++ b/f5tts.service @@ -0,0 +1,15 @@ +[Unit] +Wants=systemd-networkd.service + +[Service] +User=ymq +Group=ymq +WorkingDirectory=/share/ymq/run/f5tts +Type=forking +ExecStart=/share/ymq/run/f5tts/run.sh +StandardOutput=append:/var/log/f5tts/f5tts.log +StandardError=append:/var/log/f5tts/f5tts.log +SyslogIdentifier=f5tts + +[Install] +WantedBy=multi-user.target diff --git a/logs/stderr.log b/logs/stderr.log index c9b065d..e69de29 100644 --- a/logs/stderr.log +++ b/logs/stderr.log @@ -1,15 +0,0 @@ -Building prefix dict from the default dictionary ... -Loading model from cache /tmp/jieba.cache -Loading model cost 0.794 seconds. -Prefix dict has been built successfully. -/d/f5tts/py3/lib/python3.12/site-packages/asyncssh/crypto/cipher.py:29: CryptographyDeprecationWarning: ARC4 has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.ARC4 and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0. - from cryptography.hazmat.primitives.ciphers.algorithms import AES, ARC4 -/d/f5tts/py3/lib/python3.12/site-packages/asyncssh/crypto/cipher.py:30: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0. - from cryptography.hazmat.primitives.ciphers.algorithms import TripleDES -/d/f5tts/py3/lib/python3.12/site-packages/transformers/models/whisper/generation_whisper.py:509: FutureWarning: The input name `inputs` is deprecated. Please make sure to use `input_features` instead. - warnings.warn( -You have passed task=transcribe, but also have set `forced_decoder_ids` to [[1, None], [2, 50360]] which creates a conflict. `forced_decoder_ids` will be ignored in favor of task=transcribe. -Passing a tuple of `past_key_values` is deprecated and will be removed in Transformers v4.43.0. You should pass an instance of `EncoderDecoderCache` instead, e.g. `past_key_values=EncoderDecoderCache.from_legacy_cache(past_key_values)`. -The attention mask is not set and cannot be inferred from input because pad token is same as eos token. As a consequence, you may observe unexpected behavior. Please pass your input's `attention_mask` to obtain reliable results. -/d/f5tts/py3/lib/python3.12/site-packages/transformers/models/whisper/generation_whisper.py:509: FutureWarning: The input name `inputs` is deprecated. Please make sure to use `input_features` instead. - warnings.warn( diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..74e5cad --- /dev/null +++ b/run.sh @@ -0,0 +1,5 @@ +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 & + diff --git a/samples/test.wav b/samples/ymq.wav similarity index 100% rename from samples/test.wav rename to samples/ymq.wav