Skip to content
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

Closed
wants to merge 1 commit into from
Closed

Conversation

lym0302
Copy link
Contributor

@lym0302 lym0302 commented Jan 21, 2022

20220121-【新增】python TTS server

#1368

@lym0302 lym0302 added this to the r0.2.0 milestone Jan 21, 2022
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


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
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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]
Copy link
Collaborator

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.
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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)
Copy link
Collaborator

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))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

soundfile可以接受float,写int16的。

@zh794390558 zh794390558 changed the title fix #44, test=tts [server] tts server Jan 21, 2022
@lym0302 lym0302 deleted the xiaoming-branch branch May 6, 2022 05:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants