This commit is contained in:
yumoqing 2025-05-25 16:32:02 +00:00
parent 33c535bec4
commit 2b4d7594dc
2 changed files with 9 additions and 1 deletions

View File

@ -14,6 +14,7 @@ from cached_path import cached_path
from appPublic.textsplit import split_text_with_dialog_preserved
from appPublic.uniqueID import getID
from ahserver.serverenv import get_serverenv
from filetxt.loader import fileloader
import pycld2 as cld
import cn2an
@ -199,14 +200,19 @@ class F5TTS:
debug(f'{gen_text=} inference error\n{format_exc()}')
async def inference_stream(self, prompt, speaker, speed_factor=1.0):
total_duration = 0
async for d in self._inference_stream(prompt, speaker, speed_factor=speed_factor):
sampels = d['audio'].shape[0]
duration = samples / d['sample_rate']
audio_b64=audio_ndarray_to_base64(d['audio'], d['sample_rate'])
d['audio'] = audio_b64
d['duration'] = duration
d['done'] = False
txt = json.dumps(d, ensure_ascii=False)
yield txt + '\n'
d = {
'done': True
'done': True,
'duration': total_duration
}
txt = json.dumps(d, ensure_ascii=False)
yield txt + '\n'
@ -329,6 +335,7 @@ def init():
g.test1 = awaitify(test1)
g.add_voice = f5.add_voice
g.UiError = UiError
g.filelaoder = fileloader
g.UiMessage = UiMessage
if __name__ == '__main__':

View File

@ -6,4 +6,5 @@ cn2an
apppublic
sqlor
ahserver
file2text
# git+https://github.com/SWivid/F5-TTS