-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[server] tts server #1371
[server] tts server #1371
Conversation
liangyunming seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
from paddlespeech.cli.utils import MODEL_HOME | ||
|
||
from paddlespeech.s2t.utils.dynamic_import import dynamic_import | ||
from paddlespeech.t2s.frontend import English |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里应该有很多无效的import吧
pre-commit run -a 后修改对应的warning/error
from paddlespeech.t2s.frontend.zh_frontend import Frontend | ||
from paddlespeech.t2s.modules.normalizer import ZScore | ||
|
||
from ttsserverexecutor import TTSServerExecutor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同目录下用 .ttsserverexecutor
|
||
from ttsserverexecutor import TTSServerExecutor | ||
|
||
from pattern_singleton import Singleton |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
speechserving下创建个 setup.py 把依赖放进去 pattern-singleton
具体参考主目录里的setup.py文件
from pattern_singleton import Singleton | ||
|
||
class TTSEngine(metaclass=Singleton): | ||
"""[summary] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
summary要写下
"""[summary] | ||
|
||
Args: | ||
metaclass ([type], optional): [description]. Defaults to Singleton. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[type] [descritpion]都是需要写的。 这里应该写 __init__的参数。可以在 init 下面写 docstring
# Copyright 2021 liangyunming(liangyunming@baidu.com) | ||
# | ||
######################################################################## | ||
"""tts fastapi Request basemodel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Request params
from fastapi import FastAPI, Response | ||
from fastapi.responses import StreamingResponse | ||
from pydantic import BaseModel | ||
from scipy.io import wavfile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
尽量用soundfile
from request import TTSRequest | ||
|
||
import yaml | ||
from yacs.config import CfgNode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
上面两个可以选一个用
tts_audio_path = item_dict['tts_audio_path'] | ||
audio_format = item_dict['audio_format'] | ||
|
||
wav_data, sample_rate = tts(sentence, spk_id, speed, volume, sample_rate, tts_audio_path, audio_format) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tts(**item.dict())
|
||
buf = io.BytesIO() | ||
wav_norm = wav_data * (32767 / max(0.01, np.max(np.abs(wav_data)))) | ||
wavfile.write(buf, sample_rate, wav_norm.astype(np.int16)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
soundfile可以接受float,写int16的。
20220121-【新增】python TTS server
#1368